Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript

In the previous post I mentioned about manipulating SharePoint PeoplePicker control using JavaScript, in this post I will show how to validate the InputFormTextBox contol using custom JavaScript function. Here is the nice post by Becky Isserman on why not to use RequiredFieldValdator or InputFormRequiredFieldValidator with InputFormTextbox.

function ValidateComments()
{

    //retrieve the text from rich text editor.
    var text = RTE_GetRichEditTextOnly(
"<%= rteComments.ClientID %>");

    if (text != "")
    {
        return true;
    }

    else
    {
        alert('Please enter your comments.');

        //set focus back to the rich text editor.
        RTE_GiveEditorFocus(
"<%= rteComments.ClientID %>");
        return false;
    }

    return true;
}

<SharePoint:InputFormTextBox ID="rteComments" runat="server" RichText="true" RichTextMode="Compatible" Rows="10" TextMode="MultiLine" CausesValidation="true" ></SharePoint:InputFormTextBox>

<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" OnClientClick="return ValidateComments()" CausesValidation="true" />

- Jignesh

posted @ Friday, March 12, 2010 3:06 PM
Print

Comments on this entry:

# re: Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript

Left by ankita at 10/5/2010 3:02 PM
Gravatar
thanks for the article . great help .

# re: Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript

Left by Vinodh at 12/17/2010 11:50 AM
Gravatar
Thank you , was very useful

# re: Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript

Left by Anju at 6/28/2011 1:20 PM
Gravatar
Thanks a lot posting.That saved my day

# re: Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript

Left by Praveen Mandalapu at 2/28/2012 1:17 AM
Gravatar
Thanks alot, saved my day..!

Your comment:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«May»
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678