Reader Level:
Articles

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

By Sagar P on January 06, 2014
Disabled or read-only to multiple lines of a text field and single line text in an edit form in a SharePoint list.
  • 0
  • 0
  • 5286

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("<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.

Sagar P

I have 4+ yrs of experience. I am an MCP, MCTS .NET & Sharepoint 2010, MCPD Sharepoint 2010, and MCSD HTML 5.  I am currently working on Sharepoint 2010, MOSS 2007, Sharepoint 2013, C#, ASP.NET, and SQL Server 2... Read more

COMMENT USING

Trending up