Assignment 8 Scripts Solution

Script I

Create an HTML page containing a form that simulates a credit card payment submission form. The user will input values in each field of the credit card form. Validate the form per credit card requirements. Cater for Visa, Mastercard and American Express credit card types. Use the following rules for credit card number validation:

Visa card numbers always begin with the numeral 4 and use 16 digits.

MasterCard numbers always begin with the numeral 5 and use 16 digits.

American Express card numbers always begin with the numeral 3 and use 15 digits.

If the information entered is incorrect based on the card type selected, ask the user to either select a different credit card or change the card number. If the information entered is correct, acknowledge that.

Script 2

Create an HTML page containing a form that includes 2 textboxes (one for name, one for email address), a textarea, a dropdown box, a set of radio buttons, and a set of checkboxes. The action attribute of the form tag should be an alert displaying the valid information entered into the form. Add JavaScript event handlers to the form to validate the form. If there is a problem, display the problem with the page in some way. Possible ways to do this are:

a pop-up box

displaying the problems in a new window in red text

displaying the problems in red text next to each field

Validate that an entry has been made in each form element. Validate that the email address contains an @ sign.

Add a second drop down list and make this second one dynamic, i.e. make the choices that appear in the second drop down list depend on what choice is made in the first list.

Zip the files created into a zip file called and submit the zip file.

Your assignment grade will be based on correctness of JavaScript code, readability of the Javascript code, code comments and final HTML page layout.
Powered by