advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Download the sample application for this article.
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
 

Exploring Secrets of Windows Form Validation

If you're tired of writing custom validation code for every input field in your applications—and of fixing the resulting validation errors—then you'll welcome the generic validation engine described in this article, which can automate many validation scenarios. 


advertisement
nput validation is something that every program needs, and every programmer dreads. Most developers craft hard-coded program logic to verify that a phone number consists of 7 or 10 digits; that an IP address consists of 4 octets; that a country name matches 1 of 193 choices, etc. While .NET 2.0 provides some support for streamlining input validation, it barely scratches the surface of automating and simplifying the input validation process. If you ever search MSDN for the topic, you'll find most of the articles discuss hard-coded validation—but maintaining hand-written, custom code for each element that requires validation is a maintenance nightmare.


Furthermore, it's unnatural to conceptualize the steps of validation as programming steps (i.e. if this then that...); it's far more intuitive to consider the qualities of the data to be validated. For example, if you were describing the input, you might say, "It should be between five and eight characters; it should be numeric and non-negative; it should always end in the digit '5,' etc."

It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?



advertisement