function validate_form( ) { var emailID=window.document.forms[0].email valid = true; if ( window.document.forms[0].name.value == "") { alert ( "Please fill in the your 'name'" ); window.document.forms[0].name.focus(); valid = false; } else if ( window.document.forms[0].loc.value == "0") { alert ( "Please select your 'location'" ); window.document.forms[0].loc.focus(); valid = false; } else if ( window.document.forms[0].attn.value == "0") { alert ( "Please select the 'type' of enquiry" ); window.document.forms[0].attn.focus(); valid = false; } else if ( window.document.forms[0].phone.value == "") { alert ( "Please fill in the your 'phone number'" ); window.document.forms[0].phone.focus(); valid = false; } else if ( window.document.forms[0].company.value == "") { alert ( "Please fill in the your 'company name'" ); window.document.forms[0].company.focus(); valid = false; } else if ( (!echeck(window.document.forms[0].email.value)) || (window.document.forms[0].email.value==null) || (window.document.forms[0].email.value=="") ){ window.document.forms[0].email.focus(); valid = false;} else if ( window.document.forms[0].message.value == "") { alert ( "Please enter your message" ); window.document.forms[0].message.focus(); valid = false; } return valid; } function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ alert("Invalid E-mail Address") return false } else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ alert("Invalid E-mail Address"); window.document.forms[0].txtemail.focus(); return false } else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ alert("Invalid E-mail Address"); window.document.forms[0].txtemail.focus(); return false } else if (str.indexOf(at,(lat+1))!=-1){ alert("Invalid E-mail Address"); window.document.forms[0].txtemail.focus(); return false } else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ alert("Invalid E-mail Address"); window.document.forms[0].txtemail.focus(); return false } else if (str.indexOf(dot,(lat+2))==-1){ alert("Invalid E-mail Address"); window.document.forms[0].txtemail.focus(); return false } else if (str.indexOf(" ")!=-1){ alert("Invalid E-mail Address"); window.document.forms[0].txtemail.focus(); return false } return true }