Friday, May 31, 2013

How to get People Picker entry using JavaScript Client Object Model

Hi ,

To fetch People picker value from People Editor Control, JQuery comes to rescue when we talk in terms of Javascript Client Object Model.

Approach 1 :
var loginName = $("span.ms-entity-resolved").attr("title"); // Returns the Login Name eg. ind\ali.yasir
var displayName = $("span.ms-entity-resolved div:first-child").attr("displaytext"); Returns Display Name as 'Ali Yasir'

Approach 2:
var loginName = $("textarea[title='People Picker']").val();
var displayName = $("div[title='People Picker']").text();

Hope this will help !!

1 comment:

  1. how about multiple people pickter controls on the form

    ReplyDelete