CIS 119 - Form validation using regular expressions
The objectives of this assignment are:
use regular expressions
validate data on a form
Overview
This assignment involves validating form data. Although HTML5 has some validation built-in
now, it is not fully suppoorted in all browsers, and this assignment requires you to
use regular expressions to do the validation and not use HTML5 validation features.
Program Specifications
Create a web page with a nicely laid-out form containing fields for
name, age, zipcode, telephone number, and password. Include reset and
submit buttons. Use regular expressions to
validate the fields. If the form validates, send the form data to
http://kermit.kishwaukeecollege.edu/~dklick/dataChecker.php.
as a POST request. You should get a response that tells you if the data you sent is valid.
Of course, your validation routine could still be incorrect if you haven't tested enough
possibilities or your validation routine is excluding some correct answers from being sent.
The names of the text input elements should be name, age,
zip, phone, and pass. The exact names
are important since that is what the receiving page will be expecting.
Display form validation error messages either below the form or to the right of each input field.
Display all error messages instead of stopping when the first error is encountered.
All form fields should be required.
The name field must be non-blank. This does NOT require a regular expression.
The age field must be a valid integer between 16 and 120. The valid integer part should be checked
using a regular expression. Once you know the field contains a valid integer, then you can check
the range of ages using regular if statements [eg. if (age >= 16)].
The zipcode field should allow the following formats:
#########
#####
#####-####
##### ####
The phone number should allow the following formats:
an optional area code which must be a 3 digit number not starting with a zero;
it may be followed by an optional space or dash
a seven digit number, of which the first may not be a zero; there may be an
optional dash after the third digit
The password field must be between eight and sixteen characters long, and include at least one
lowercase letter, one uppercase letter, one digit, and one character which is not a letter, digit,
or whitespace character.
If there are any validation errors, then display all of them and do not let the form be submitted.