Create script.js

I chose to manually validate data entered using jQuery rather than the HTML5 validation as I wasn't keen on the error messages that pop-up for the purposes of my website. I have yet to sort out the server-side validation using PHP.

I start by hiding the panel that will eventually display the success/failure message sent from the php file. I then perform validation upon the user clicking the submit button. Any existing error classes are removed where a red border is used to indicate data entered was invalid. I then loop through each input field ensuring no fields were left empty and then use regex to ensure that the phone and email patterns are compliant.

The ajax $.post is used to send data entered to the sendmail.php file and the output from the php file sent to the .html page. The hidden message panel is display while at the same time the form is hidden. The return false ensures that the normal submit operation is interrupted so that the ajax call to post is done instead.