Disable multiline textbox and single line textbox in SharePoint using jQuery

Disable multiline textbox using jQuery in SharePoint 2010

Here we will discuss how we can disable or make readonly to multiline textbox and single line textbox in SharePoint 2010/2013/2016 using jQuery. We will make this is Edit form in SharePoint list. You can also do the same in SharePoint new list form.


Also read some SharePoint tutorials:
Dropdown list with multiple selection option in SharePoint 2010

Hide Personalize this page option in SharePoint 2010

Hub Sites SharePoint Online Office 365 Tutorial Download PDF Free

You can use SharePoint Designer to make a field read only. Here is a method to make a field readonly using Jquey and a Content Editor Web Part Edit the EditForm.aspx page

By default it comes like below:

Disable multiline textbox using jQuery in SharePoint 2010
Disable multiline textbox using jQuery in SharePoint 2010

If the Edit Page option is missing from the Site Actions menu, use the ToolPaneView=2 URL parameter.



Ex:
1. /EditForm.aspx?ToolPaneView=2
2. Add a Content Editor Web Part
3. Add the following code (in this example, “Question” is the name of my field):

Below is the jQuery Code:

$(document).ready(function () {

ConvertTextboxToLable(‘Title’);
ConvertTextareaToLable(‘Description’);
});

//Convert TextArea to Lable
function 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 Lable
function 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);
}

After this, it will appear like below:

Disable multiline textbox using jQuery in SharePoint 2013
Disable multiline textbox using jQuery in SharePoint 2013


Hope this will be helpful.

Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials:

About Sagar Pardeshi

I am Developer working on Microsoft Technologies for the past 6+years. I am very much passionate about programming and my core skills are SharePoint, ASP.NET & C#,Jquery,Javascript,REST. I am running this blog to share my experience & learning with the community I am an MCP, MCTS .NET & Sharepoint 2010, MCPD Sharepoint 2010, and MCSD HTML 5,Sharepoint 2013 Core Solutions. I am currently working on Sharepoint 2010, MOSS 2007, Sharepoint 2013,Sharepoint 2013 App Dev, C#, ASP.NET, and SQL Server 2008.

View all posts by Sagar Pardeshi →