Disabled or read-only to multiple lines of a text field and single line text in an edit form in a SharePoint list.
Objective
Use of SharePoint Designer to make a field read only. Here is a method to make a field readonly using jQuery and a Content Editor Web Part.
Edit the EditForm.aspx page
If the Edit Page option is missing from the Site Actions menu then use the ToolPaneView=2 URL parameter.
For example
/EditForm.aspx?ToolPaneView=2Add a Content Editor Web PartAdd the following code (in this example, “Question” is the name of my field):Using the code
$(document).ready(function () {
ConvertTextboxToLable('Title');
ConvertTextareaToLable('Description');
});
//Convert TextArea to Lablefunction ConvertTextareaToLable(colName) {
var txtHTML = $("textarea[Title='" + colName + "']").html();
var tdColumn = $("textarea[Title='" + colName + "']").closest('td');
var tdColumnHTML = $(tdColumn).html();
$(tdColumn).html("<div style='display:none'>'" + tdColumnHTML + "'</div>");
$(tdColumn).append(txtHTML);
}
//Convert Textbox to Lablefunction ConvertTextboxToLable(colName) {
var txtHTML = $("input[type=text][Title='" + colName + "']").val
();
var tdColumn = $("input[type=text][Title='" + colName +
"']").closest('td');
var tdColumnHTML = $(tdColumn).html();
$(tdColumn).html("<div style='display:none'>'" + tdColumnHTML +
"'</div>");
$(tdColumn).append(txtHTML);
}
Summary
In this article we have several requests for a solution for setting fields as read only in an Edit Form.