Validating the SharePoint InputFormTextBox / RichText Editor using JavaScript
Posted
by Jignesh Gangajaliya
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Jignesh Gangajaliya
Published on Fri, 12 Mar 2010 10:06:30 GMT
Indexed on
2010/03/12
9:57 UTC
Read the original article
Hit count: 1294
In the previous post I mentioned about manipulating SharePoint PeoplePicker control using JavaScript, in this post I will explain how to validate the InputFormTextBox contol using JavaScript. 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
© Geeks with Blogs or respective owner