Vb net control validating event

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 the client-side function, you should strongly consider writing it using Java Script, since Java Script is universally recognized by browsers while VBScript is only recognized by Internet Explorer.

It should be noted that these exercises use the Data control with other controls bound to it.

The Data control does a lot for you "behind the scenes" and you may be tempted to use it in your applications, but be advised that the Data control is rarely used in professional applications – the norm is to write your own database access code so that you have complete control over the process.

Imagine that you run a Web site for math nerds and that you have a form for users to provide some personal information to improve your knowledge of your site's demographics.

Being math nerds, you may wish to ask them what their favorite prime number is.

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.

(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.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!

Leave a Reply