Disable People Picker, Lookup Fields in SharePoint List Forms

In continuation with my earlier post: How to Make SharePoint List Column (Form Field) Read Only, There are questions on disabling (or making them read-only) People Picker, Lookup Fields in SharePoint List Forms. Here I’m sharing the jQuery scripts to disable people picker / Lookup fields in SharePoint list forms (NewForm.aspx, EditForm.aspx).

jQuery to Disable People Picker Fields in SharePoint List Forms:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function() {
 //People Picker Field to Disable 
 var FieldName = "Project Manager";

 //Get People Picker using its field name
 var element=$("tr:contains("+FieldName+"):last").find("div[title='People Picker']");

 //Disable People Picker
 element.attr('disabled','true');  

 //Disable "Check" and "Browse" Buttons in People Picker field
 $(this).find("a[Title='Check Names']").click();
 $(this).find("a[Title='Browse']").attr("onclick","");
});

//Enable the fields during "PreSaveAction" otherwise, their values will not get saved!
function PreSaveAction()
{
var FieldName = "Project Manager";
var element=$("tr:contains("+FieldName+"):last").find("div[title='People Picker']");
element.removeAttr('disabled');

//Enable Save
return true;
}
</script>

How to Disable Lookup Fields in NewForm/EditForm:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {

//Get the field using its  name
var element=$('nobr:contains("Parent Project")').closest("td").next("td");

//Disable Entire TD
element.attr('disabled','disabled');  
});

//Enable the fields during "PreSaveAction" otherwise, their values will not get saved!
function PreSaveAction()
{
var element=$('nobr:contains("Parent Project")').closest("td").next("td");
element.removeAttr('disabled');

//Enable Save
return true;
}

</script>

Same code works to disable Multi-Choice fields in SharePoint NewForm.aspx or EditForm.aspx. The above code can be made shorten as:

$('nobr:contains("Parent Project")').closest("td").next("td").attr("disabled", "disabled"); 

I wrote it elaborated.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

2 thoughts on “Disable People Picker, Lookup Fields in SharePoint List Forms

  • Thank you. Did just what as I needed.

    Reply
  • Thanks for the post. Your site is very helpful!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *