none
How to catch the change eveent of people picker using jquery in Sp 2013? RRS feed

  • Question

  • My People picker field is shown below.

    <div class="inner-wrap">
    <label >Approver 1</label><label> <div class="innerclass"  id="peoplePickerDivAppr1"></div></label></div>

    How to get the change event function of the above people picker using jquery?

    Wednesday, February 1, 2017 4:13 PM

All replies

  • Hi sudhir,

    We can catch the change event with People Picker like below:

     this.SPClientPeoplePicker.SPClientPeoplePickerDict.peoplePickerDiv_TopSpan.OnValueChangedClientScript=function (peoplePickerId, selectedUsersInfo) {
            console.log('inside OnValueChangedClientScript');
        };

    Here is a article about using People picker events using JavaScript for your reference:

    SharePoint 2013: Client Side People Picker

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, February 2, 2017 3:05 AM
  • Hi,

    Hope the below code helps you:

    $("input[title='PeoplePicker Name']").focusout(function (){
    		var getIDPeoplePicker=$("div[Title='PeoplePicker Name']")[0].id;
    		var ppobject = SPClientPeoplePicker.SPClientPeoplePickerDict[getIDPeoplePicker];
    		var usersobject = ppobject.GetAllUserInfo();
    		if(usersobject.length > 0 && $("input[title='Email ID']").val()==0)
    		{
    			var orgEmail = usersobject[0].EntityData.Email;
    			$("input[title='Email ID']").val(orgEmail);
    		}
    	});	
    In the above example, when the people picker value is entered (change the value "People Picker Name" to your control name) and focused out, we are setting the Email ID of the person entered in people picker control in the control named "Email ID"


    Cheers,
    Maruthu
    Please click the 'Mark as Answer' if this post solves your problem or "Vote As Helpful" if it was useful! :)
    Explore the SharePoint

    Thursday, February 2, 2017 3:53 AM
  • This is not working in  my case.Please let me know the  working solution ?
    Thursday, February 2, 2017 8:06 AM
  • Hi sudhir,

    If the people picker is  just a html client side control, then just use Jquery to catch change events:

    $(selector).change(function)

    jQuery change() Method

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com


    Tuesday, February 7, 2017 8:36 AM
  • Hi,

    Is there any update?

    If the post helps you, you can mark it as answer to help other community members to find the solution quickly.

    Have a nice day!


    Please click the "Mark as Answer" button if this post solves your problem or "Vote As helpful if it was helpful! :)
    Explore the SharePoint

    Friday, June 16, 2017 4:22 PM