For this assignment, you will write an HTML form, and a JavaScript to validate it before it is sent.
First of all, before I forget, let me point out that it doesn't really matter what the action of the form is. If you just want to get some kind of feedback that says "Yeah, it submitted", you can use
ACTION="http://www.genome.wi.mit.edu/cgi-bin/echo.pl" method="GET"
Use a different script for the action, if you like, but NOT one in which mail is sent to anyone other than yourself. Especially your TA or instructor.
I recommend starting from the example in the book, which I've mirrored here.
The form should have:
Here are the formats you must validate for the fields:
For the phone number, state, and zip fields, validate them as soon as they are changed. If they are invalid, alert the user, and select the field for their convenience.
For the other inputs, validate them when the submit button is pressed. If they are invalid, alert the user, and select the field for their convenience. If more than one of the inputs is invalid, it is okay to complain about only one when the submit button is pressed.
You should explain exactly what the problem is in the alert; the necessary formats should also be made clear to the user on your form.
If the submit button is pressed and everything is okay, put up an alert thanking the user by name.
Yes, you may use it. Don't forget to give credit to the original author.
Note also that my validation requirements are stricter than the ones used in the original code. So you will have to rework the code fairly extensively. You will not get credit for turning in functions that only do the same validation as the original functions, in the cases where the requirements have changed.
No, it means that when it comes time to validate those fields, all we require is that they not be empty. If they contain any text, consider that acceptable.
Oops. No, I mean, make it clear to the user that exactly two choices must be selected. In other words, make sure it says so right there with the SELECT. Also, if the user does not do this, make sure that the alert explains exactly what the problem is.
No. Please write code that takes the user's two-character input and checks it against the list of valid inputs (states). If it doesn't make sense to you to do this with an array, you can write 51 if statements, or however else you like.
I think that's it. As always, contact me at wyvern@cs.umbc.edu with any questions, and check the page for revisions, which will be clearly marked.
Steve