SharePoint 2013: Enhanced/ Rich TextBox Validation Using JQuery

Posted: December 25, 2015 in SharePoint2013

In this article you will learn about the Rich TextBox validation using JQuery in SharePoint 2013.

I observed that the mandatory enhanced/rich text box of SharePoint 2013 doesn’t throw an error when we cut the content from it from the edit/new form and it allows us to save the form without any content in rich text box. The article describes the steps to remove this error.



On the new/edit form we have enhanced/rich text which is a mandatory field. If we edit the rich text box and cut the content present inside it, the validation doesn’t work. The issue has been resolved.


Need to avoid the div tags and get data alone from multiline textbox field using the following script,

Step 1: Navigate to your SharePoint 2013 site.

Step 2: From this page select the Site Actions | Edit Page.

Edit the page, go to the “Insert” tab in the Ribbon and click the “Web Part” option. In the “Web Parts” picker area, go to the “Media and Content” category, select the “Script Editor” Web Part and press the “Add button”.

Step 3: Once the Web Part is inserted into the page, you will see an “EDIT SNIPPET” link; click it. You can insert the HTML and/or JavaScript as in the following:

  1. “text/javascript”>
  2.     $(document).ready(function()
  3.     {
  4.         var reg1 = new RegExp(
    [^, “”);
  5.         var reg2 = new RegExp(

$”, “”);

  •         var Fieldname = $(“ nobr:contains(‘Field Name’)”).parent().parent().parent().find(“”).html().replace(reg1, “”).replace(reg2, “”);
  •         var contenttext = $(“ nobr:contains(‘Field Name’)”).parent().parent().parent().find(“”).text();
  •         if (contenttext == “”)
  •         {
  •             $(“ nobr:contains(‘Field Name’)”).parent().parent().parent().find(“”).html(Fieldname);
  •         }
  •     });


    Leave a Reply

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

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

    Google+ photo

    You are commenting using your Google+ 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 )


    Connecting to %s