28 September 2011

ASP:RegularExpressionValidator force validation with JavaScript

Hi All,

You often have the situation when you want to force the validation of the ASP:RegularExpressionValidator using JavaScript.
This is usually because for some reason the Validator is not actioned automatically like: the submit button was initially disabled, or the value of the input to validate is changed through JavaScript.
So you can force the validation of the ASP:RegularExpressionValidator using the Page_ClientValidate JavaScript function.

<asp:TextBox ID="test" runat="server" 

Calling that function will cause the validation of all Validators on the page, so if you want to validate only a Validator which corresponds to a specific ValidationGroup then you would call that JavaScript function like this:

Good luck,


Saqlain Hemani said...

Thank you, this solved my issue!!!

Roman Gherman said...

I'm glad to see that my articles are helping people. ;)

Post a Comment

your thoughts are welcome:

Post a Comment

Need more? Leave comments and subscribe to my blog.