A10: Regular Expressions

On This Page


Overview

The main points of this assignment are to:

  • Validate form information
  • Use regular expressions

Specifications

Tutorial Exercises

  1. Complete the in-chapter tutorial exercises (step-by-step instructions to complete the case study) that are listed throughout chapter Tutorial 7.3. You must follow the steps exactly and turn in all the files to make it work correctly. This does NOT include the Review Assignment nor any Case Problems at the end of the chapter.

Form and Form Validation

For this project, you will update your single page form from the last assignment to validate form data using regular expressions. The updates are shown in emphasis font.

  1. Call your page the same name as before: form.html.
  2. Remember that your form must collect the following information:
    1. Buyer's first and last name
    2. Street address
    3. City
    4. State
    5. Zip code
    6. Telephone number
    7. Credit card type (use those shown in the tutorial case)
    8. Credit card number
    9. Credit card expiration with month and year fields
  3. In addition, the form must show a subtotal for the order in the amount of $50.00
  4. Also, the form must allow the user to select one of the following shipping options:
    1. Federal Express ($10.00)
    2. UPS ($8.50)
    3. USPS ($6.75)
  5. Once the user selects the shipping method, 5% tax should be added to the combined amount for the subtotal and shipping and displayed to the user.
  6. Include the following validation before the form is submitted:
    1. Buyer's first and last name are 50 characters or less
    2. Street address is 6 characters or more
    3. City is 2 characters or more
    4. State is exactly 2 letters (not just characters)
    5. ZIP code is 0, 5 or 9 (5-4) digits (no letters or non-digit characters allowed)
    6. Credit card is between 13 and 16 digits long (including 13 and 16) with blank spaces removed and validated using the Luhn formula
    7. Credit card expiration is a valid date not more than 10 years in the future
    8. Shipping method is selected

    Note you do not need to use JavaScript for validation if your HTML form ensures a correct value. For example, using a selection list for the state would preclude the need to validate the state, assuming that all the selection list option values are exactly two characters. However, your selection list must allow all valid entries (see state abbreviations).

  7. You must use regular expressions in the validation process for the ZIP code and credit card number.
  8. In addition to validating the form, send the form information to a page named receipt.html and display at least the following data from the form:
    1. Buyer's first and last name
    2. Total order amount (including tax and shipping)
  9. Be sure to put your JavaScript code for the form in various functions, and to place at least one function in a file named form.js.
  10. Once you complete this page, test your JavaScript to ensure it works without error.

Other Specifications

  1. Complete a README.txt file following the instructions for homework.
  2. Zip your files and submit the zipped archive file to WebCT as explained in the section of this document: What to Turn In.

Hints

  • To verify your credit card validation, you can use the test numbers found here

Extra Credit

This extra credit is worth 2 points.

  1. Complete Case Problem 2 of Tutorial 7 that starts on page JVS 406 of your textbook.
  2. Include the extra credit solution in your assignment zip file.

Make certain that your README.txt file lists any extra credit attempted.

Grading Criteria

The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.

Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

For information on grading policies, including interpretation of scores, see the course information page.

Tutorial Exercises

  • 8: Demonstrates mastery of the assignment
    • Applies concepts from the lessons appropriately
    • Follows the steps exactly
    • Exercises perform correctly
    • No JavaScript errors encountered during operation
  • 6: Has all the major functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • May deviate from the specified steps in some way
    • Implementation seems more complicated than necessary.
    • May have one minor JavaScript warning or error
  • 4: Has much of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Deviates from the specified steps in some way
    • Implementation seems excessively complicated.
    • May have JavaScript warnings or errors
    • Missing support files
  • 2: Serious functional problems but shows some effort and understanding
    • Follows at least 1/2 of the of the specified steps
    • Has a major error (detected by the browser) or many minor errors
    • Implementation seems very convoluted
    • Demonstrates few techniques from the lesson
  • 0: Does not execute or not turned in

Form and Form Validation

  • 10: Demonstrates mastery of the form and form validation techniques
    • Has extra features or demonstrates techniques beyond the assignment
    • Applies concepts from the lessons appropriately
    • Meets all specifications (see above) with particularly elegant solutions
    • Runs with no error conditions reported by the browser
    • Generates correct output given correct input
    • Validates the form and verifies all the specified conditions
    • Behaves in a reasonable way in response to incorrect data
    • Validation functions are clearly defined and reusable
  • 8: Has all the functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • Meets all specifications (see above)
    • Runs with no error conditions reported by the browser
    • Generates correct output given correct input
    • Validates the form and verifies all the specified conditions
    • May have one minor error in the form or validation
    • Implementation seems more complicated than necessary.
  • 6: Has most of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets all but one of the specifications (see above)
    • Runs with no error conditions reported by the browser
    • Validates the form and verifies all the specified conditions
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors in the form or validation
  • 4: Has some of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets at least 1/2 of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have JavaScript warnings or errors in the browser
    • Missing support files
  • 2: Serious functional problems but shows some effort and understanding
    • Meets less than 1/2 of the of the specifications (see above)
    • Has a major error (detected by the browser) or many minor errors
    • Implementation seems very convoluted
    • Demonstrates few techniques from the lesson
  • 0: Does not execute or not turned in

REAME.txt File

  • 2: README.txt file submitted with specified information included
  • 1: README.txt submitted but some information was not included
  • 0: No README.txt submitted

Extra Credit Case Study

  • 2: Shows complete mastery of the problem.
  • 1: Shows some understanding of the problem.
  • 0: Not submitted, no substantial work, or has major problems

Maximum Score: 20, plus extra credit

What to Turn In

Submit your assignment following the instructions for homework. Create a single zip file with the following:

  1. README.txt file
  2. All the files needed for the Tutorial Exercises to work correctly
  3. Your single web page, named form.html
  4. Your JavaScript file, named form.js
  5. Any other files needed to support your single html page
  6. If you chose to complete the extra credit, then all the files needed for the extra credit to work correctly.

You must submit all the files needed for your assignment to work properly. Do not assume that the instructors has any files. Your assignment must work as submitted.

Home | WebCT | Announcements | Schedule | Room Policies | Course Info
Help | FAQ's | HowTo's | Links

Last Updated: November 25 2006 @23:47:58