COP3832, Assignment 5
Due Monday 4/9 at the start of class.
Upload the script and hand in a printout.
There will be several different HTML pages displayed by this script
-
The Login Page
-
The Form Page
-
The Confirmation Page
The Login Page will display a form with a Submit button and
a text box for the User Name. When the button is clicked:
-
Validate that the User Name is 2 to 6 letters followed by 2 digits;
or 2 to 5 letters followed by 3 digits.
-
If the User Name is invalid, then redisplay the Login Page
with an appropriate error message.
-
If the User Name is valid, then display the Form Page as follows
-
If the User Name is already in the database, then fill in the Form
Page with the user's data.
-
If the User Name is not in the database, then display an empty Form
Page.
The Form Page will have the following.
-
Display the User Name on the page as plain text (do not display it
in a form element.)
-
The user must fill in the following fields:
-
Name. Be sure that the name contains only letters and spaces.
-
A Phone Number. The allowable formats are the following. Extra spaces
are allowed anywhere in the string.
-
(999)999-9999
-
999-999-9999
-
999.999.9999
-
9999999999
-
A multiple selection list of Hobbies with at least 5 options. At least
two options must be selected by the user, but not all of them.
-
Display the form elements in a table.
-
A Submit button. When this information is submitted, the script should
verify that each field has been filled in or selected, and that it meets
the above requirements.
-
If there are invalid fields, then redisplay the Form Page with appropriate
error messages, and use the background color of a <td> field to highlight
the invalid fields. Be sure that the user's previous choices are still visible.
-
If all the fields are valid, then display the Confirmation Page.
The Confirmation Page will have the following:
-
Display the user's information as plain text (do not display them in form
elements.) Reformat the data as follows
-
Name: the first letter of each name in the name should be upper case,
all others should be lower case. Use uc, lc, and ucfirst. (Hint: split on
' ').
-
User Name: display the letters as lower case followed by the digits.
-
Phone Number: (999)999-9999. If number was entered in a different
format, then force it to this format.
-
Hobbies: List all selected hobbies in an unordered list.
-
Display the following buttons in a form:
-
Edit: if clicked, then the Form Page is redisplayed, with all
of the user's information filled into the form.
-
Confirm: if clicked, then write the user's information to a database.
Use the User Name as the key field. Redisplay the Confirmation
Page with an extra message indicating that the data has been entered
into the database.
-
New User: if clicked, then display an empty Login Page.
-
Please note that the data is not entered into the database until the
user presses Confirm on the Confirmation Page.