1

How to control ASP.NET Validator Controls Client Side validation from JavaScript?

1 Answer 1

1

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.
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.