Friday 4 April 2014

Validate People Picker Value is Resolved or not using jQuery

Dear Readers,

Recently I was working on a people picker control and using jQuery I have to validate whether the people editor field is resolved or not. I played with people picker control using the IE developer tool and finally came up with the solution using jQuery. Its a very simple jQuery implementation and hope it might help somebody. For greater understanding of the below snippet have a look at my previous post here


var htmlPeopleEditor = $("[id$='peopleEditorProductOwner_upLevelDiv']");
var isResolved = $("#divEntityData", htmlPeopleEditor).attr("isResolved");

if (isResolved == "False" || isResolved == "false") {

          alert("Not Resolved");

}


Now if you look at the above snippet, there is an isResolved attribute that gets set when you try to resolve a people picker field. With the help of this attribute you can ensure whether your people picker field is resolved or not.

Hope that helps !


Cheers,
Geetanjali

             

6 comments:

  1. Also if you throw in some username in the input editor field inside the client people picker, then call its AddUnresolvedUserFromEditor method, you can resolve a name yourself.

    ReplyDelete
  2. Could you please let me know if there are more than one people picker controls in form.how to make disabled or set the value in people picker
    Thanks in Advance

    ReplyDelete
    Replies
    1. Refer to my below post for reference. Hope that can give you some inputs.

      http://myloveforsharepoint.blogspot.in/2014/02/accessing-people-editor-control-using.html

      Delete
  3. People title "Assign To" column validation

    function fnassign(){
    try{


    var len3=$("div [title='Assign To']").find(".sp-peoplepicker-resolveList").find("span").length;
    if(len3!=3){
    alert("Please enter the AssignTo value");
    return false;
    }
    }

    }
    catch(e)
    {
    alert(e);
    }
    }

    Click here more details

    ReplyDelete
  4. Could please give me a sample of peoplepicker event handling with JQuery? As soon as leave the people picker control I need to check that if the picker is resolved or not. I need the which event I should trigger....help is appreciated.

    ReplyDelete
  5. alert($(".ms-inputuserfield #content").text());

    ReplyDelete