7Aug/090
Use JavaScript to access the control Validators in ASP.NET pages
Sometimes, we want to access the Validators such as RequiredFieldValidator and CompareValidator in the client side and do something according to the user’s behavior. This can be done only use JavaScript.
Here is what I did in my application:
<script type=”text/javascript”>¨
function void myFunction(){
if (typeof (Page_ClientValidate) == ‘function’){
Page_ClientValidate();
}
if (Page_IsValid){
// Do something
}
else{
if (!Page_Validator[0].isvalid){
// Do something
}
}
}
</script>