01.09.17 - 05.07.17
Better Form Validation
Objective: To incorporate JavaScript, CSS, and DHTML into online forms
pastdue
Webpage properly formed and valid | 5 pts |
All required information collected | 5 pts |
Appropriate input controls used for collecting each piece of information | 5 pts |
Form controls cannot be left blank | 5 pts |
Form is neat and easy to follow | 5 pts |
Client informed of errors with red field and label markings | 25 pts |
Field marking returned to black when field is focused | 10 pts |
Errors displayed at the top of the form describing problems with incorrect submitted fields | 25 pts |
Form doesn't submit unless all fields are valid | 15 pts |
Total | 100 pts |
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:
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.