Posts
16
Comments
100
Trackbacks
18
Monday, January 29, 2007
Triggering a validator through javscript

In this post, I talked about enabling or disabling a validator client-side. Someone had commented asking how to change the status of a control from valid to invalid. The following javascript works at least for required field validators, I haven't tested it with anything else (but I imagine it should work just fine). Again, this is 2.0, I haven't tested this in 1.1:

var myValidator = document.getElementById('<%=reqField.ClientID%>');
ValidatorValidate(myValidator);

For a required field validator at least, the causes the same actions as clicking on a button on the page.

Hope this helps!

posted @ Monday, January 29, 2007 3:45 PM | Feedback (0)
News