Clienside Validation Before Server Side
My issues: 1) Postback always occurs 2) Is that the correct way to see if requiredFieldValidator is valid client side? What I would like: User clicks the visible click button. This
Solution 1:
Nope, you just have to add the validators like this:
<asp:TextBoxrunat="server"ID="txtEmail" /><asp:RequiredFieldValidatorErrorMessage="The email is required"ToolTip="The email is required"Text="(*)"ControlToValidate="txtEmail"runat="server" /><asp:ValidationSummaryrunat="server"DisplayMode="BulletList"ShowMessageBox="true" />
And the validation will be executed on the client whenever you try to submit your form, you do not need to manually execute the validation
The output will be something like:
Edit 1
<scripttype="text/javascript">functionvalidate() {
var val = Page_ClientValidate('');
if (!val) {
for (i = 0; i < Page_Validators.length; i++) {
if (!Page_Validators[i].isvalid) {
$("#" + Page_Validators[i].controltovalidate).qtip();
}
}
}
return val;
}
</script><asp:ButtonOnClientClick="return validate();"Text="Post"runat="server" />
Post a Comment for "Clienside Validation Before Server Side"