InputFormTextBox Validation(Rich TextBox in Sharepoint)
In this post I will tell how to validate the InputFormTextBox contol using custom JavaScript function…if u Use RequiredFieldValdator or InputFormRequiredFieldValidator with InputFormTextbox U ll get some validation Issues Onclick Validation Button…Instead of RequiredFieldValidation Just do with CustomValidator .
This is an example of Client-side validation Using Cutomvalidator…
<sharepoint:InputFormTextBox ID=”txtDetailInfoRequired” CausesValidation=”true”
AllowHyperlink=”true” RichText=”true” RichTextMode=”FullHtml” runat=”server” TextMode=”MultiLine” Rows=”6″ Columns=”10″ />
AllowHyperlink=”true” RichText=”true” RichTextMode=”FullHtml” runat=”server” TextMode=”MultiLine” Rows=”6″ Columns=”10″ />
<asp:CustomValidator ID=”CustomeDetails” runat=”server” ValidationGroup=”validate” ClientValidationFunction=”ValidationForRichDetails” ControlToValidate=”txtDetailInfoRequired” SetFocusOnError=”true” ValidateEmptyText=”true” Display=”Dynamic” ErrorMessage=”*”>
Inside Javascript tag Define this function...
<script language=”javascript” type=”text/javascript”>
function ValidationForRichReason(source, arguments) {
var text = RTE_GetRichEditTextOnly(“<%= txtReasonofrequest.ClientID %>”);
if (text != “”) {
arguments.IsValid = true;
}
else {
function ValidationForRichReason(source, arguments) {
var text = RTE_GetRichEditTextOnly(“<%= txtReasonofrequest.ClientID %>”);
if (text != “”) {
arguments.IsValid = true;
}
else {
//set focus back to the rich text editor.
RTE_GiveEditorFocus(“<%= txtReasonofrequest.ClientID %>”);
arguments.IsValid = false;
}
}
</script>
arguments.IsValid = false;
}
}
</script>
Onclick…Button…
<asp:Button ID=”btnSubmit” runat=”server” Text=”Submit” CssClass=”nav_new” ValidationGroup=”validate” />
if any doubts please comments here...good luck
No comments:
Post a Comment