CSC443
LAB EXERCISE 1 JavaScript Review and Form Handling
1. Accessing Form Elements Using "Name"
The following Web page (Figure 1.1) contains a form that allows the user to enter appropriate
information. When the user has entered the required information, and the Display Info button is
clicked, the information entered is displayed in the textarea. It will not be displayed if user does not
enter the name, or does not select any radio buttons, selection list, or the checkboxes. (Note: The
name is displayed in all capital letters).
The code for the Web page in Figure 1.1 is given below (Figure1. 2). Type in the code in Notepad and
save the file as ex1_1.htm. Open the file in a browser and enter the values and click on the Display
Info in the form to see the result.
Figure 1.1
Figure 1.2
2. Validating the Form
A Web page contains a simple registration form to set the username and password. The e-mail
address must entered correctly following the name@[Link] format. The password must be
between 6 and 8 characters and must contain at least one lowercase letter, one uppercase letter and
one digit.
The user will be alerted if the textboxes are empty or the password or username selected is not valid.
The screen shots of the page are shown below (Figure 2.1). The code for the page is given in Figure
2.2. Type in the code in Notepad and save the file as ex1_2.htm. Run the file in a browser to see the
results.
Figure 2.1
Figure 2.1
Figure 2.2