Added input validation and jQuery.

Added validation for input fields and alerts for incorrect entries.
Rewrote some code using jQuery.