Geeks With Blogs

News Disclaimer
The views expressed on this weblog are mine and do not necessarily reflect the views of my employer.

All postings are provided "AS IS" with no warranties, and confer no rights.



Jignesh Gangajaliya's blog on Software Architecture and Development

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 on Friday, March 12, 2010 3:06 PM ASP.NET , JavaScript , SharePoint | Back to top


Comments on this post: Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript

# re: Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript
Requesting Gravatar...
thanks for the article . great help .
Left by ankita on Oct 05, 2010 3:02 PM

# re: Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript
Requesting Gravatar...
Thank you , was very useful
Left by Vinodh on Dec 17, 2010 11:50 AM

# re: Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript
Requesting Gravatar...
Thanks a lot posting.That saved my day
Left by Anju on Jun 28, 2011 1:20 PM

# re: Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript
Requesting Gravatar...
Thanks alot, saved my day..!
Left by Praveen Mandalapu on Feb 28, 2012 1:17 AM

# re: Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript
Requesting Gravatar...
I tried using this with a custom list edit form with no real success.
At first I replaced the SharePoint:FormField with the SharePoint:InputFormTextBox and implemented the script to bind the control to the SharePoint list
(ie. __designer:bind="{ddwrt:DataBind('u',concat('ff2',$Pos.....)

When I ran a test, the control appear in the form but the data was not bound.

I then reverted back to the original SharePoint:FormField and tried to bind the validator using the ID of the FormField, however, in SP2010 the ID's are dynamically generated and this would not work.

I would really like to be able to validate this field with the on change or blur events but can't seem to get my hooks into those.

Any Suggestions?

JG
Left by John Gregory on Oct 09, 2012 5:56 PM

Your comment:
 (will show your gravatar)


Copyright © Jignesh Gangajaliya | Powered by: GeeksWithBlogs.net | Join free