In this hour, we will cover
As we have examined in previous hours, collecting user input through an ASP.NET page is a relatively easy task. Unfortunately, when we're collecting a user's input, there is no guarantee that he has provided the desired input in an acceptable format. That is, imagine that you are asking the user to specify his weight, much like we did with the BMI calculator a few hours ago. What should happen if, for weight, the user enters something like "Far too much"? Ensuring that user input is in a proper format is a technique known as input validation and is the topic for this hour. If you have had experience with other dynamic web page creation technologies, such as ASP, PHP, or JSP, you likely are more than familiar with input validation. Performing input validation in these older technologies was a real headache. Fortunately, ASP.NET makes input validation a breeze with the help of validation controls, which are Web controls designed to do nothing else but perform input validation. We will examine how to use four validation controls in this hour: the RequiredFieldValidator, the CompareValidator, the RangeValidator, and the RegularExpressionValidator. |