$(document).ready(function() {
	// on submit check fields	
	 $("form").submit(function () { 
		errormsg = "";
		if ($('#name').val() == "") {
			errormsg = "Please enter your name\n";
		}
		if (!is_valid_email($('#email').val())) {
			errormsg += "Please enter a valid email address\n";
		}
		if ($('#captcha').val() == "") {
			errormsg += "Please fill in the captcha field\n";
		}
		if ($('#comment').val() == "") {
			errormsg += "Please leave a comment";
		}
		if (errormsg == "") {
			return true;
		}else{
			alert(errormsg);
			return false;	
		}
		 
	});
	
})

function is_valid_email (email)
{
	var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return regex.test(email);
}
