Reputation: 3435
How to control ASP.NET Validator Controls Client Side validation from JavaScript?
Upvotes: 1
Views: 432
Reputation: 116977
If you mean writing custom validation functions on the client side, this is fully supported by the CustomValidator. Simply give it the name of your javascript function that you'd like to use for validation, for example:
<script language="javascript">
function MyTextBoxValidation(source, args)
{
if (valid)
args.IsValid = true;
else
args.IsValid = false;
}
</script>
<asp:CustomValidator ID="MyValidator" runat="server"
ClientValidationFunction="MyTextBoxValidation"
ControlToValidate="MyTextBox" />
If, however, you just want to fire off the existing validation logic, you can always use the following script:
if (Page_ClientValidate())
{
// Do stuff, we're valid here.
}
Upvotes: 1