Read Only People Picker Fields in SharePoint List Forms

Posted: July 12, 2014 in SharePoint2010

Introduction

How to make a SharePoint List Column (form field) read only. There are questions on disabling (or making read-only) People Picker and Lookup Fields in SharePoint List Forms. Here I’m sharing the jQuery scripts to disable People Picker / Lookup fields in SharePoint list forms (EditForm.aspx).

Code

<script language=”javascript” src=”/JSLibrary/jquery-1.9.0.min.js” type=”text/javascript”></script>

<script language=”javascript” type=”text/javascript”>

$(document).ready(function () {

var control = $(“textarea[title=’People Picker’]”)[0];

/* Detect browser*/

if (navigator.appName == ‘Microsoft Internet Explorer’) {

control.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[1].style.display =”none”;

}

else {

control.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[2].style.display =”none”;

}

var innerHtml = control.parentNode.parentNode.innerHTML;

control.parentNode.style.display = “none”;

control.parentNode.parentNode.parentNode.parentNode.parentNode.innerHTML = control.parentNode.parentNode.parentNode.parentNode.parentNode.innerHTML + “<span class=’fieldsTitle’>”+ $(‘.ms-inputuserfield #content’).text() + “</span>”;

});

</script>
Before this jQuery the People Picker was like this:

People Picker

People Picker test

Summary

In this article we explored a disabled/read-only people picker field and also determining whether they work in every browser.

Advertisements

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