McCoey Lab on Forms--4/6/2005

Send me Your Money

Okay--we are going to do an online car auctions. Find four cars you would like to buy. Save the pictures of the cars. Try to get cars within the same general type and price range.

You are going to build a form.

The form needs to allow the user to pick the car they wish to purchase, submit a bid for the car and an email address.

Once the user selects the car, puts in the bid and enters a valid email, the form should process the bid. If the bid is within a valid range for the car (within $200 or your price) you should acknowledge that the user has won the bid and the car will be held for them--the may be displayed by opening a banner page with the congratuations message. If the bid on the car is out of range, the user should be told to try and bid again. The user should then be given the option to start over.

You need to create a form with the elements
Car names

Text element for bidding

Text element for email.

Button for submit and one for reset.

You need to write two functions one for validation and one for action for the form

Validaton Function

When the info is entered and the user clicks the submit button (onsubmit event), you need to call a validate function to check that a car has been picked, a entry has been entered for the bid and a valid email is entered. If the entries are not valid, the user needs to receive an alert box telling the error and the cursor needs to be positioned on the invalid entry (use the focus method for the element). The validate function should return a false. If all the entries are valid, the validate function should return a true.

Action Function

If all the entries are valid and the validate function returns a true, then form action will be executed. The form action should be a call to another JS function. This function will now validate that the bid is in the correct range. The bid entered on the form should be within $200.00 of the actual price. Use a common price for all the bids. If the bid is within the range, the function should open a window that congratulates the user and notifies them they have won the auction for the car.. If the bid is not within the range, the user should receive an alert box telling what the problem with the bid (was it too high or too low) and the cursor should be repositioned back to the bid element on the form to allow them to re-try.

Try your page, test it with valid and invalid entries. Submit your files to Dr. Blum.