Threesuns

Email

Contact

All Semesters

Semesters

All Courses

Courses

Scripting (Blended)

CSYS2033

3 credits

Labs

Better Form Validation

Lab

100 points

Requirements

Webpage properly formed and valid5
All required information collected5
Appropriate input controls used for collecting each piece of information5
Form controls cannot be left blank5
Form is neat and easy to follow5
Client informed of errors with red field and label markings25
Field marking returned to black when field is focused10
Errors displayed at the top of the form describing problems with incorrect submitted fields25
Form doesn't submit unless all fields are valid15
Total100 pts

Objective

To incorporate JavaScript, CSS, and DHTML into online forms

Instructions

For this lab you will need to build the form described below and validate it, informing users of errors with JavaScript/DHTML that will mark incorrect or incomplete form fields and their labels in red. The lab should also dynamically generate field specific errors that should be displayed at the top of the form.

The form should contain the following fields at a minimum:

  • First name
  • Last name
  • Middle initial
  • Street Address
  • City
  • State
  • Zip Code
  • Username
  • Password
  • Password Confirmation
  • User Agreement

The javascript you write to validate this form should confirm that none of the information is missing at the time the client submits the form and the two password fields should be confirmed to contain the same value. The user agreement should be a control that allows the user to signify that they have read and understood a user agreement (which doesn't really exist so don't worry about having one) that must be marked 'Yes' or something similar before the form will be submitted.

In this lab the form should have the ability to mark fields and their labels in red if it is determined that there is problem with any particular field. For example, if the user forgets to type their first name in the firstname field, when the form is submitted, the javascript should recognize that the first name is missing and should, in response, color the 'First Name' label appearing next to the firstname field red (bold would also be nice) and put a red box around the first name field.

At the time that a user focuses a red marked field (onfocus), the javascript in your page should change the color of the field label back to regular black and remove the red box around the field indicting that the user has corrected the error.
If the user then resubmits the form and an error still exists, the field should be changed to red again.

You are welcome to make any further refinements to the form that you feel are appropriate and you should correct any problems that you had with the first version of this form.