Welcome to www.mmclean.ca!
2 Nov 2026
Summary
This page demonstrates how to validate different types of data using "rule-based" validation.

DL» form_validation.zip
PDF» Validation Details

"Rule-based" Form Validation

One of the most common tasks facing web developers is validating user input. Relying on end-users for data is the most prone to errors. This is not because end-users have no idea what they are doing but rather, they are human and humans make mistakes. Perhaps they make a typo or they are not 100% sure what they are supposed to enter. Verifying the data entered is a critical step before submitting data to be processed. In the event there is a bug in the web application, it is that much more difficult to isolate the problem if the data being processed is not known to be correct. Validation must be performed at various levels but starting with the form data before it is submitted is the obvious first step.

The sample form presented demonstrates a "rule-based" system to validate data. The data types include in the sample are some of the more challenging types to validate like an email address or a domain name. Validating an email address, for example, may sound simple but is, in fact, a bit more involved to do it properly than what most people think.

The validation rules in this system can only determine if the data is "well formed" but cannot determine if the data accurate. For example, an email address may be properly formed but the mailbox may not exist.

View Source to see the rules configured for the Test Form.

Test Form

Port :: int
Timing Delay (secs) :: float
IP Address
Domain Name
Address
Email Address
Credit Card