This is a very basic and that useful example, only made to show you how you may use the Custom Validator.
One annoying task that most every developer has had to face in the past is form validation.
You might also have certain restrictions on the values.
Even if users correctly enter an integer, for example, you might need to make sure that the value falls within a certain range.
With classic ASP, performing form field validation was annoying, at best. NET fixes all of this by its use of validation Web controls. NET Web controls designed specifically to validate form field entries. NET contains a Required Field Validation control, which, as its name suggests, can be used to ensure that the user enters a value into a form field (such as a Text Box). NET provides the following form field validation controls: This article does not aim to discuss the specifics of all of these validation Web controls.
Developers had to write their own validation routines and cut and paste them in the various ASP scripts that needed to employ form validation techniques. Rather, it will dissect a particular control, the Custom Validator validation control.
For example, you don't want to process a form that's missing critical information.
When users enter values into an HTML form, the values that they enter are strings.
Therefore, you also have to make sure that the values that users enter can be correctly converted to the appropriate data types.If I enter 1 January 1000 as the min or max value I get an error saying value cannot be converted to type date, but if I use another format it picks up my entered text as invalid.Below is my code: This works, but the caveat is that this allows dates that may be out of range of SQL dates less than 1753 or you may have a date range (no future date entries).Of course, doing serverside validation requires a postback to validate, but in most cases, that's not really a problem. If it's exactly 8 characters long, we return true, otherwise we return false.In this example, we will simply check the length of the string in the Text Box.