function ValidateForm1(){ var flag = true; var message = 'Please, fill in all mandatory fields.'; var showcheck = -1; if (showcheck=='0') { message = 'Incorrect verification code.'; flag = false; } if (document.ContactForm1.field2.value.length==0){ flag = false; } if (document.ContactForm1.field3.value.length==0){ flag = false; } if (document.ContactForm1.field4.value.length==0){ flag = false; } if (!document.ContactForm1.field3.value.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)) { flag = false; message += '\nEmail: is invalid.'; } if (flag == false) { alert(message); } else { document.ContactForm1.submit(); } }function createRequestObject(){ try { xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert('Sorry, but your browser doesn\'t support XMLHttpRequest.'); } return xmlhttp; } var http = createRequestObject(); function ValidateResult1() { if(http.readyState == 4) { ValidateForm1(); } } function CheckForm1() { ValidateForm1(); }