/*Check mail address string entered in field*/ function checkmailaddress(str) { /* define global variables*/ var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) /*find the first occurrence of an invalid string input*/ if (str.indexOf(at)==-1){ alert("This is NOT a invalid E-mail address!") //String is not valid return false } /*find the first occurrence of an invalid string input*/ if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ alert("To process this form a valid email address is mandatory. A valid email address looks like this ' billme@yahoo.com '. Please try again!") //String is not valid return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ alert("To process this form a valid email address is mandatory. A valid email address looks like this ' billme@yahoo.com '. Please try again!") //String is not valid return false } if (str.indexOf(at,(lat+1))!=-1){ alert("To process this form a valid email address is mandatory. A valid email address looks like this ' billme@yahoo.com '. Please try again!") //String is not valid return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ alert("To process this form a valid email address is mandatory. A valid email address looks like this ' billme@yahoo.com '. Please try again!") //String is not valid return false } if (str.indexOf(dot,(lat+2))==-1){ alert("To process this form a valid email address is mandatory. A valid email address looks like this ' billme@yahoo.com '. Please try again!") //String is not valid return false } if (str.indexOf(" ")!=-1){ alert("To process this form a valid email address is mandatory. A valid email address looks like this ' billme@yahoo.com '. Please try again!") //String is not valid return false } //Otherwise string is valid return true } function ValidateForm(){ var mailaddress=document.feedback.txtEmail /* Check field value for valid input*/ if ((mailaddress.value==null)||(mailaddress.value=="")){ alert("To process this form a valid email address is mandatory. A valid email address looks like this ' billme@yahoo.com '. Please try again!")/* Alert if field has no valid input*/ mailaddress.focus()/*set focus on mail address field*/ //String is not valid return false } /*Check for valid mail adress*/ if (checkmailaddress(mailaddress.value)==false){ mailaddress.value="" mailaddress.focus() /*Check for valid mail adress*/ //String is not valid return false } //String is valid return true }