/* Script developed for Sunshine Blinds, Milton Keynes. */

// Client-side form validation script for Appointment Booking page.

function formValidator() {

	var nameCheck = document.appointment_form.name.value;
	var filter = /^[a-zA-Z ]+$/;	
	if (!filter.test(nameCheck)) {
	// alert
	alert ('Please enter your name.');
	return false;
	}

	else if(document.appointment_form.postcode.value == '') {
	// alert
	alert ('Please enter your postcode. This provides us with an approximate location to aid our planning.');
	return false;
	}

	var contactnoCheck = document.appointment_form.contactno.value;
	var filter = /^[0-9 ]+$/;
	if (!filter.test(contactnoCheck)) {
	// alert
	alert ('Please enter a contact number so we can get in touch as soon as possible.');
	return false;
	}

	else if(document.appointment_form.email.value == '') {
	// alert
	alert ('Please enter your email address so we can get in touch as soon as possible.');
	return false;
	}

	var emailCheck = document.appointment_form.email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(emailCheck)) {
	alert('Please enter a valid email address.');
	return false;
	}

	return true;
}
