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:
How to to Disable Lookup Fields in NewForm/EditForm:
jQuery to Disable People Picker Fields in SharePoint List Forms:
<script src="http://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 to Disable Lookup Fields in NewForm/EditForm:
<script src="http://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 made shorten as:
$('nobr:contains(“Parent Project")').closest("td").next("td").attr("disabled", "disabled");I wrote it eloborated.