﻿function checkifvalid()
{
    // Validate Name's input
    if (document.getElementById("txtName").value == "") { alert("Please complete your Name"); document.getElementById("NameContact").focus(); return false; }

    // Validate email
    var regex = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var address = document.getElementById('txtMail').value;
		
    if(address=='')
    {
	    alert('Please complete the email address field.');
	    document.getElementById('txtMail').focus(); 
	    return false;
    }
	
    if(regex.test(address) == false)
    {
	    alert('Invalid email address. Please check.');
	    document.getElementById('txtMail').focus();
	    return false;
    }
	
    // Validate Comments box
    if (document.getElementById("areaComment").value.length < 3) { alert("Please write a comment"); document.getElementById("areaComment").select(); return false; }
	
    // Ok, let's submit
    document.ctcForm.submit();
}