Description
Practice using JavaScript.
Revisit form validation.
Assignment
This should be, hopefully, a simpler project. You’ve already got the form and the code to send
an email, or you can use the form to save a message in a database on your server, so use either
one you wish. All you have to do is change the form validation for whichever one you select to
use JavaScript, without breaking how the form works. Here’re the details:
Pick one of your forms for messaging (if you didn’t keep them both, then use the one you
still have).
o Get rid of the PHP code for input validation.
o With JavaScript, you can now do validation as you go. Put code in to validate a field
anytime the focus leaves it.
o Put more code in to check everything when the submit button is clicked. If
everything isn’t right, the button shouldn’t work – in other words, do nothing except
put up an alert to tell the user what’s wrong.
o If everything is valid, you can call a simple little PHP file that sends the mail and puts
up a success message. You don’t, of course, want to redraw the form but you should
give the user some navigation options back to your site.
You should comment your code well. If something is going wrong, neither I nor the grader
will spend a lot of time debugging your work to give you partial credit. Improve your
chances of partial credit by good comments so we can quickly figure out your intent.
Work together to figure things out but, as always, turn in your own code.
Hey, that’s it! Of course, you still need to have a JS function for each of the fields and so it’s not
completely trivial. But it really is simpler to handle validation with JS. I’m betting you can do a
better and easier job of validating the email address, now, right?
Project Report
The final step of this assignment is to create a report consisting of a cover page, an overview of
the project, sample output, and the source code. For your source code, you can simply zip up
your site files. Otherwise, we can’t see the content of your scripts. For this project, we only
need to see the files you changed or added; it’s not necessary to give us all the database layouts
or other files.
IMPORTANT: in the Conclusions section of your report, talk about how you might change the
validation for your database forms. What would you change? Would you use a similar approach
to how you changed the email forms? If yes, why? If not, why not and what would differ?