0

I want to do some operation based on the user entered in the people picker control.

My code is:

$(document).ready(function () {    
$("input[title='Project Owner']").focusout(function () {

    //var User = $("textarea[title='People Picker']").val().split("\\");
     //user = $.trim($("#Project Owner").text());
    //var user = $().SPFindPeoplePicker({
    //    peoplePickerDisplayName: "Project Owner"

    //});
    alert("Hello");
    var user = $(this).val();

    alert(user);

});
});

The foucusout() event runs perfectly but I am not getting the user name. What should I do?

users1100
  • 3,230
  • 6
  • 61
  • 114

2 Answers2

2

After searching too much I got some thing to get the display name of the user:

code is here:

$(document).ready(function () {
$("input[title='Project Owner']").focusout(function () {




    var loginName = $("span.ms-entity-resolved").attr("title");

    alert("Login Name:" + loginName);

    var displayName = $("span.ms-entity-resolved div:first-child").attr("displaytext");

    alert("Display Name :" +displayName);

});

});

Hope this helps to other.

users1100
  • 3,230
  • 6
  • 61
  • 114
0

The People Picker controls are tricky little things.

You might want to take a look at this blog post by Marc Anderson which seems to cover the ground to wish to.

Fairfield
  • 612
  • 11
  • 20