4

I've built my people picker using the normal method for client side:

// Render and initialize the client-side People Picker
function initializePeoplePicker(peoplePickerElementId) {

// Create a schema to store picker properties, and set the properties.
var schema = {};
schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = false;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '300px';
schema['Required'] = true;

// Render and initialize the picker. 
// Pass the ID of the DOM element that contains the picker, an array of initial
// PickerEntity objects to set the picker value, and a schema that defines
// picker properties.
this.SPClientPeoplePicker_InitStandaloneControlWrapper(peoplePickerElementId, null, schema);
 }

and I've set the required to true but no validation is taking place? Does this only work for server side PP controls?

S

2
  • Probably, because that validation takes place on server side if I am not wrong Commented Jan 13, 2014 at 16:38
  • 1
    yeah thought as much currently working out a way to do this client side.
    – Stephen
    Commented Jan 13, 2014 at 16:40

1 Answer 1

4

You can use javascript to validate the people picker by get all the users in that:

var peoplePickerElementId = "peoplePickerID"; 

var peoplePickerElement = SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerID_TopSpan;
var users = peoplePickerElement.GetAllUserInfo();
if(users.length > 0)
{
    //continue;
}
else
{
    alert("Required");
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.