How to control ASP.NET Validator Controls Client Side validation from JavaScript?
views:
77answers:
1
+1
A:
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.
}
womp
2009-05-21 16:39:43