Realize that there is no downside to providing client-side validation.Regardless of whether or not your Custom Validator provides client-side validation, the server-side validation will always occur. NET validation Web controls.) So, providing client-side validation only has the upside of making your custom validation more friendly for users whose browsers can support the DHTML and Java Script requirements.As you'll recall from many years ago, a prime number is a number that is only divisible by the number 1 and itself.Numbers like 13, 23, and 37 are prime, for example. NET validation control model to provide validation on the user's entry to ensure that it's prime.This is due to the fact that Java Script (and VBScript, for that matter) are type-free languages, meaning variables may assume any type.While the above code has changed syntactically from the server-side event handler example (written in VB. We simply loop from 2 to the square root of the number the user entered, checking to see if the number is evenly divided by the looping variable. Be sure to view the live demo to see the client-side validation in action!To provide client-side form validation for a Custom Validator you must first write a client-side function that takes two input parameters (for consistencies sake, call them .
(For more information on the other validation Web controls be sure to read Server Control Form Validation.) By simply using the first four ASP.NET validation Web controls (the Required Field Validator, the Compare Validator, the Range Validator, and the Regular Expression Validator), you will be able to solve the vast majority of your form validation needs.However, there may be times when you need to perform more complex validation logic.In such a scenario, you would need to use the Custom Validator to provide the validation logic. NET's validation Web controls contain a required property called With the built-in validation controls, these steps are all performed behind the scenes for us, free of charge.However, when we're using a Custom Validator, we must do this work ourselves.