CIS 119 - Form validation

The objectives of this assignment are:

  1. validate data on a form
  2. use functions in JavaScript

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 JavaScript functions without regular expressions or HTML5 to do the validation.

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 JavaScript functions to validate the form fields when the form is submitted. 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.
  7. The age field must be a valid integer between 16 and 120. To check for being an integer, create and use a JavaScript function [named something like isInteger()]. If it is a valid integer, then 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.