Posted by: R Manimaran | December 17, 2010

Auto Validate a People Picker on LostFocus event in SharePoint CustomPage

Auto Validate a People Picker on LostFocus event in SharePoint CustomPage

In the SharePoint Custom Page, I have a People Picker control, which needs to Auto validate the username entering in the control. i..e when the user leaves the control it needs to validate

1. Add a Content Page Holder and add the script.

2. Adding Script other than in Place Holder will throw the error. So add it to a Content Place Holder. Here I have added in PlaceHolderPageTitleInTitleArea.

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server">

<script type="text/javascript" >

function PeoplePickerFocusValidation()

{

var pickval=document.getElementById(‘<%=Reviewers.ClientID%>’+"_hiddenSpanData").value;

pickval= pickval.replace(/&nbsp;/gi,”);

if((pickval != null)&&(pickval != ”)&& (pickval != ‘ ‘))

{

document.getElementById(‘<%=Reviewers.ClientID%>’+"_checkNames").click();

}

}

</script>

</asp:Content>

In the PeopleEditor Control add a attribute “onfocusout” and call our javascript method.

<SharePoint:PeopleEditor

id="Reviewers"

AllowEmpty="true"

ValidatorEnabled="true"

MultiSelect="true"

runat="server"

SelectionSet="User,SPGroup,SecGroup"

onfocusOut="return PeoplePickerFocusValidation()"

width=’300px’/>

Advertisements

Responses

  1. Good Work.Very Thx


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: