SharePoint – Multiple Lines of Text Field and Single Line Text as Disabled or Read-Only

Posted: July 12, 2014 in SharePoint2010

Introduction
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(”

‘” + tdColumnHTML + “‘

“);
$(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(”

‘” + tdColumnHTML +
“‘

“);
$(tdColumn).append(txtHTML);
}
Summary

In this article we have several requests for a solution for setting fields as read only in an Edit Form.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s