Friday, January 27, 2012

How to use custom validator in asp.net

If all existing validation controls doesn't fulfill business requirements or validations then we can write our own logic and perform validations using validation control only.i.e custom validator.Custom validator can be used to perform validations in client and also to perform validations at server.Here i will given steps how to implementing custom validator at client side.

1.Place custom validator in the form and set the fallowing properties control to validate ,error msg client validation function
2.Go to source view and function with in the script tag.This function should have two arguments as CV will pass two arguments
ex:function fn(x,y)
{
}
second arguments provides 2 properties /value
i)Value ->provide the control value which custom validator is validating
ii)IsValid->bad which specifies whether validation is ok or not.
<script type="text\java script>
function checkmod(a,b){
if(b.value%10 ==0)
b.IsValid=true;
else
b.IsValid=false
}

No comments:

Bel