Hi Simon,
Client side validation API:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspplusvalid.asp
There are many ways to accomplish this task:
- you can force validators to run their validation methods by calling
ValidatorValidate(val)
- instead of using reqularexpressionvalidator, use customvalidator in
conjunction with clinetfunctionname property, and Regex DOM object (it's
easy to incorporate the same functionality as regularexpressionvalidator)
example :
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="MyValidationFunction" ControlToValidate="txt"
ErrorMessage="try again...."
OnServerValidate="CustomValidator1_ServerValidate"/>
<script runat="server">
protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
args.IsValid = System.Text.RegularExpressions.Regex.IsMatch(args.Value,
"[0-9]+");
}
</script>
<script language="javascript">
function MyValidationFunction(src, e)
{
e.IsValid = e.Value.match('[0-9]+');
// do something here...
}
</script>
--
Milosz Skalecki
MCAD
:
I have RegularExpressionValidator which validate one text box.
When my text box is validated on client I would like to do something
else.
Is there some client event of RegularExpressionValidator?
Something like after validate?
something like:
<script language="javaScript">
function afterValidate(arg){
if (arg.isValid )
{
//do something
}
}
</script>
regards,S