0% found this document useful (0 votes)
45 views4 pages

Lab 1 - JS Review - Form Handling

This document provides instructions for two JavaScript form handling exercises. The first exercise demonstrates accessing form elements by name and displaying the entered values. The second exercise validates a registration form by checking that the email is properly formatted and password meets complexity requirements, alerting the user of any invalid entries. Students are instructed to copy code samples into files and test the form validation in a browser.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views4 pages

Lab 1 - JS Review - Form Handling

This document provides instructions for two JavaScript form handling exercises. The first exercise demonstrates accessing form elements by name and displaying the entered values. The second exercise validates a registration form by checking that the email is properly formatted and password meets complexity requirements, alerting the user of any invalid entries. Students are instructed to copy code samples into files and test the form validation in a browser.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like