CMPS 491 Advanced Web Publishing
JavaScript Programming

Assignment 8, Spring 2002
Form Validation with JavaScript (Emailing Form Data)


Primary Objectives of the Assignment
 
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:
 
Use JavaScript scripts to perform the following:
 
  1. Verify that all input boxes are properly entered.  In particular,
    1. make sure that the e-mail address does not contain the following
      invalid characters:  space, slash, comma, semicolon, and colon  (  /,;:),
    2. make sure the email address contains only one @ symbol, and
    3. make sure that the e-mail address contains a period (.) after the @ symbol.
  2. Ensure that a radio button is selected.
  3. Ensure that a drop-down menu itm is selected.

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:

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