/* * Author: Isaac Rowntree (Zack Design) * URL: http://www.zackdesign.biz * Email: isaac@zackdesign.biz * Date: 26/04/2005 * * Description: This form checker validates the obtain-a-quote (index.php) and making-a-claim (how-to-apply.php) forms. * */ function vContact() { var bool = true; var counter = 0; // Test for applicant's their email counter = both (document.contact.email.value); if (counter == 1) { bool = false; } // Test that the comment has been filled in nameFirst = document.contact.comment.value; if (nameFirst == "") { if (counter == 0) { counter++; alert("You must fill in the Comments box."); bool = false; } } // Test that the name has been filled in nameFirst = document.contact.firstname.value; if (nameFirst == "") { if (counter == 0) { counter++; alert("You must fill in your First Name."); bool = false; } } // Test that the name has been filled in nameFirst = document.contact.surname.value; if (nameFirst == "") { if (counter == 0) { counter++; alert("You must fill in your Surname."); bool = false; } } // Test that the address has been filled in nameFirst = document.contact.address.value; if (nameFirst == "") { if (counter == 0) { counter++; alert("You must fill in your Address."); bool = false; } } // Test that the address has been filled in nameFirst = document.contact.city.value; if (nameFirst == "") { if (counter == 0) { counter++; alert("You must fill in your City."); bool = false; } } // Test that the address has been filled in nameFirst = document.contact.state.value; if (nameFirst == "") { if (counter == 0) { counter++; alert("You must fill in your State."); bool = false; } } // Test that the address has been filled in nameFirst = document.contact.postcode.value; if (nameFirst == "") { if (counter == 0) { counter++; alert("You must fill in your Postcode."); bool = false; } } return bool; } function both (email) { // Check the email address for correct formatting pos = email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/); if (email == "") { alert("You must provide your email address"); return 1; } else if (pos) { alert("The email address may only have these characters: a-z, A-Z, @, period, underscore. It may not begin with an @ or a period."); return 1; } else { return 0; } }