CMSC 210
Spring 2017
Exercise
03/01/2017
Simple Form Validation lab
Due: Fri, March 3
5pm

Assignment:   (worth 5 exercise points)      

Task:

Create a nice-looking form that has the following fields:

  • Name (first and last name in one field is fine)
  • Email address
  • Re-enter email address
  • Phone number
The page must also have a button labelled Validate.   When clicked, this button should ensure that the form is okay.
  • a descriptive error message should appear if the Name field is left blank
  • a descriptive error message should appear if the Phone number field is left blank
  • a descriptive error message should appear if the Email  field is left blank
  • a descriptive error message should appear if the Re-enter Email field does not match the Email  field
  • if there are no errors, a message should appear saying that everything looks okay.
NOTES:
  • if no errors, the okay message needs to be on the page itself NOT an alert box.
  • error messages may be in an alert box or on the page itself
  • error messages must indicate WHAT is missing, not just "missing field"
  • Options for giving errors:
    • one error at a time
      • let them know of AN error
      • let them fix it and hit the button again
    • all errors at once.
    • some errors at once, but perhaps not all
EXTRA CREDIT:
  • Phone validation
    • Add an error if the phone number is not valid  (eg does not have 9 digits)
    • Handle the possibility that they might put in ( )  or -'s  in the number.
  • Name change
    • Automatically capitalize the person's name when they enter it.
  • State
    • Add  a pull-down select menu for state.    The menu must have "Select State" as the default visible option.   The actual states need to be below that.
    • It is an error if a state has not been chosen.
    • If the user chooses Virginia, add a field to the form that asks for the name of their town.
  • Business?
    • Add a checkbox that allows the user to indicate they have a business.   When they check this box, add a field for them to type in the name of the business
  • Merchandise
    • Let them also sign up to purchase things.  For example:
      • our company tshirt ($15 each)
      • our promo dvd ($3 each)
      • be sure to give a "total" for their purchases.
      • Companies are charged an extra "business" fee, but individuals are not.

Handin:

Publish your folder to your account.    I will be looking at the following URLs:
http://cs.longwood.edu/~youruserid/210/ValidForm/ (replacing youruserid as appropriate)