none
How to disable Enhanced Rich text box (multiple line of text column) in SPD form using JQuery in SharePoint 2016?

    Question

  • Hi,

    I want to disable Enhanced Rich text box (multiple line of text column) on page load in SPD edit/new form using JQuery.

    I tried multiple solutions from SP 2013 and SP 2010 but in vain.

    Kindly help.

    Regards,

    Amien

    Tuesday, July 11, 2017 6:17 AM

All replies

  • Hi Amien123,

    To disable "Multiple line of text" fields when you add an item, you can try code below to disable it:

    <script type="text/javascript" src="/code.jquery.com/jquery-2.1.0.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    $("div[id^=CustomTitle]").attr("disabled", "disabled"); //Disable the "Multiple line of text" fields
    })
    </script>

    Here is a similar issue post for your reference:

    https://social.msdn.microsoft.com/Forums/office/en-US/e5cd87f0-3b52-416c-9661-36e02cfbd8ce/disable-fields-using-jquery-in-sharepoint-2013?forum=sharepointgeneral

    Best Regards, 

    Lisa Chen 


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, July 12, 2017 11:38 AM
    Moderator
  • Hi Amien,

    To add to what Lisa posted, you can try the below code as well:

     $("textarea[title='Title of the Column']").attr("disabled", false);

    Instructions with screenshots in this MSDN forum discussion for your reference:

    Enable and Disable and clear textarea box based on Dropdown selection


    Please click the "Mark as Answer" button if this post solves your problem or "Vote As helpful if it was helpful! :)
    Explore the SharePoint


    Wednesday, July 12, 2017 1:07 PM
  • Hi Maruthachalam,

    I have already tried this but do not work in SharePoint 2016 as it seems that the HTML of multiline textbox (with Enhanced Rich Text) is changed in SharePoint 2016.

    Regards,

    Amien

    Wednesday, July 12, 2017 1:14 PM
  • Hi Lisa,

    I tried this in SharePoint 2016, but do not work. Can you try in SharePoint 2016 and confirm? Multiline textbox with enhanced rich text.

    Regards,

    Amien

    Wednesday, July 12, 2017 1:16 PM
  • Hi Amien,

    Can you share the screenshot of the Text Area using Developer Tools? The HTML part of the Text Area in SharePoint 2016.


    Please click the "Mark as Answer" button if this post solves your problem or "Vote As helpful if it was helpful! :)
    Explore the SharePoint

    Wednesday, July 12, 2017 1:17 PM
  • Hi Maruthachalam,

    Fyi,

    Wednesday, July 12, 2017 1:31 PM
  • So, it is a Rich Text box with HTML enabled.

    The above code which I & Lisa shared will work for Rich Text with Plain Text format. The Rich Text with HTML format in SharePoint is a combination of DIV, SPAN, P tags. I found an article in stack exchange which may be useful to you. I haven't tested it. This may help you!

    Disable Text Entry Into Rich Text Area Using JavaScript

    Code for reference:

    function DisableTextArea(title) {  
        // Hide the textarea and get it's content, note that the content comes formatted with HTML tags.
        var newOutput = $("textarea[title='"+ title +"']").hide().val();  
    
        // Add text area content to the parent tag for the area. This provides a read only output of the text area.
        $("textarea[Title='"+ title +"']").closest("span").append( newOutput );  
    
        // Hide the rich text editor toolbar.
        $("textarea[Title='"+ title +"']").closest("span").find("table[id$='_toolbar']").hide();
    
        // Hide the rich text editor window.
        $("textarea[Title='"+ title +"']").closest("span").find("iframe[title='Rich Text Editor']").hide();
    
        // Hide the link to HTML editing info, visible within non IE browser.
        $("textarea[Title='"+ title +"']").closest("span").parent("span").find("span.ms-formdescription").hide();
    
        // Hide any text within the parent div, as entry isn't allowed we don't need the text describing input.
        $("textarea[Title='"+ title +"']").closest("td").contents().filter(function(){
            return(this.nodeType == 3);
        }).remove(); 

    Please click the "Mark as Answer" button if this post solves your problem or "Vote As helpful if it was helpful! :)
    Explore the SharePoint

    Wednesday, July 12, 2017 1:57 PM
  • Hi Amien123, 

    Is there anything update? 

    Why not just hide the Enhanced Rich text box (multiple line of text column) in edit/new form?

    Navigate to list settings->Click the corresponding content type->click the Enhanced Rich text box (multiple line of text column)->choose hidden->ok:

    Best Regards, 

    Lisa Chen 


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, July 17, 2017 2:06 AM
    Moderator
  • Hi Amien123, 

    I have done a test again in my SharePoint 2016 and i can disable Enhanced Rich text box (multiple line of text column) in SharePoint 2016. 

    Refer to the following steps:

    Create an Enhanced Rich text box (multiple line of text column) named mm. 

    Using F12 to find the id (mm_0151cde2-39a8-4d9b-bf48-ba696ef04440_$TextField_topDiv) of the Enhanced Rich text box.

    Add a content edit web part in New/Edit form, add the following code: 

    <script src="http://code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script> 
    <script>
    $(document).ready(function(){
    $("div[id^='mm_0151cde2-39a8-4d9b-bf48-ba696ef04440']").attr("disabled","disabled");	
    });
    </script>

    Note: using prefix match:

    $("div[id^='mm_0151cde2-39a8-4d9b-bf48-ba696ef04440']").attr("disabled","disabled");

    Best Regards, 

    Lisa Chen 



    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, July 20, 2017 12:04 PM
    Moderator
  • Perfect! I had the same issue and it worked for me like a charm.
    Monday, April 9, 2018 1:44 PM