CMPS 491 Advanced Web Publishing
JavaScript Programming
Assignment 8, Spring 2002
Form Validation with JavaScript (Emailing Form Data)
Primary Objectives of the Assignment
- To check the validility of a name box
- To check the validility of a password
- To check the validility of an e-mail address
- To check the selection of a radio button
- To check the selection of a drop-down menu item
One of the most useful purposes of JavaScript is to validate users'
form data before the data is sent to Web servers for processing.
This validation is necessary not only to eliminate blank fields but also
to ensure that the data is in the correct format. Validating
form data at the client-side with JavaScript is both faster and more
efficient than the validating form data at the server-side with CGI
scripts. For this assignment, do the following:
Part A -- Creating a Survey Form (HTML Document)
Create an HTML document to generate a survey form that contains
the
following form elements:
- Four input boxes
(one for the visitor's name, two for password
verification, and one for an email address)
- Two radio buttons (for male and female)
- A pull-down menu (for age groups)
- A textarea (for comments)
- A submit button
- A reset button
Use JavaScript scripts to perform the following:
- Verify that all input boxes are properly entered. In particular,
- make sure that the e-mail address does not contain the following
invalid characters: space, slash, comma, semicolon,
and colon ( /,;:),
- make sure the email address contains only one @ symbol, and
- make sure that the e-mail address contains a period (.) after
the @ symbol.
- Ensure that a radio button is selected.
- Ensure that a drop-down menu itm is selected.
Note: In this assignment, checking the validity of
the user password is simple. Simply make sure that when a password
is entered twice, the password entered is identical for both entries.
There is no need to write a Perl CGI on the server that checks the
master password database.
Part B -- Creating a CGI Script for Emailing Form Data
The address of the sendmail program on our Web server is:
/usr/sbin/sendmail. Your CGI script should open a pipe to re-direct
the output of the script to the sendmail program.. Your script also
needs to specify the recipient of the email. The recipient should be
your email address for this assignment. These things can be
accomplished
by the following statements:
#!/usr/bin/perl
require "subroutines.lib";
&Parse_Form;
$recipient = 'yourEmailAddress';
:
Finally, your script generates a Thank You page to acknowledge
receipt of the survey. On this Thank You page, your script should
also display the survey data.
Click Here for an example of
this
assignment
Return to CMPS 335 Home Page
Return to Web Site Home Page