SharePoint list form People Picker Read-Only -Scripts

2018-03-09 08:53:02

Following code I have used to make my list form fields read-only. This type of code will work for text fields only. How to do similar things for people picker/person field?

var elements = document.body.getElementsByTagName("INPUT");

// loop through all the elements till we find an element with type text and title as name of our field

for (index = 0; index < elements.length; ++index) {

if (elements[index].type == "text") {

if (elements[index].title == "Title") //Field name

{

console.log(elements[index].title);

elements[index].readOnly = true;

}

}

}