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
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:
Summary
In this article we explored a disabled/read-only people picker field and also determining whether they work in every browser.
No comments:
Post a Comment