CIS 119 - Form validation using regular expressions

The objectives of this assignment are:

  1. use regular expressions
  2. 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.

form validation example
Form validation example

Program Specifications

  1. 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.
  2. 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.
  3. Display form validation error messages either below the form or to the right of each input field.
  4. Display all error messages instead of stopping when the first error is encountered.
  5. All form fields should be required.
  6. The name field must be non-blank. This does NOT require a regular expression.
  7. 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)].
  8. The zipcode field should allow the following formats:
          #########
          #####
          #####-####
          ##### ####
  9. The phone number should allow the following formats:
  10. 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.
  11. If there are any validation errors, then display all of them and do not let the form be submitted.
  12. If there are no errors, then submit the form data as a POST request to: http://kermit.kishwaukeecollege.edu/~dklick/dataChecker.php
  13. Error messages should be cleared if there are any changes to the text boxes or if the Clear button is clicked.
form validation example with errors
Form validation example with errors

Grading rubric

  1. 5 pts: The page has proper documentation comments and follows current standards.
  2. 5 pts: Name and age are properly validated.
  3. 5 pts: Zipcode is properly validated.
  4. 5 pts: Phone number is properly validated.
  5. 5 pts: Password is properly validated.
  6. 5 pts: The form is not submitted and all errors are displayed when submission is attempted if there are any errors.
  7. 5 pts: If there are no errors, the form data is submitted to the server page to check the data.
  8. 5 pts: Displayed error messages are cleared if there are any changes to input fields or if the Clear button is clicked.