function update(){ if(document.frmUpdates.email.value == ""){ alert("E-mail field cannot be left blank."); document.frmUpdates.email.focus(); return false; } //IsValidEmail() ensures valid e-mail addresses in e-mail field: if(!IsValidEmail(document.frmUpdates.email.value)){ document.frmUpdates.email.focus(); return false; } return true; } function IsValidEmail(emailfield) { var iAt; var iAt2; var iPeriod; var iSpace; var iLength; var sFirstChar; var sLastChar; var pattern; var res; var field = new String(emailfield); iAt = field.indexOf("@", 1); iLength = field.length; sFirstChar = field.substring(0,1); sLastChar = field.substring(iLength-1, iLength); if(field.indexOf("..") > 0) { alert("Please correct the e-mail address. Two periods together are not allowed."); return false; } if(field.indexOf(".@") > 0) { alert("Please correct the e-mail address. A period can not preceed the @ symbol."); return false; } if(iAt == -1) { alert("Please correct the e-mail address. An @ is required."); return false; } iAt2 = field.indexOf("@", iAt + 1); if(iAt2 != -1) { alert("Please correct the e-mail address. There can be only one @ symbol."); return false; } iPeriod = (field.indexOf(".", iAt + 1)); if(iPeriod == -1) { alert("Please correct the e-mail address. A period is required."); return false; } if(iPeriod == (iAt+1)) { alert("Please correct the e-mail address. A period can not follow the @ symbol."); return false; } if(iPeriod == (iAt-1)) { alert("Please correct the e-mail address. A period can not preceed the @ symbol."); return false; } iSpace = (field.indexOf(" ", 1)); if(iSpace > 0) { alert("Please correct the e-mail address. No spaces are permitted."); return false; } pattern = new RegExp("[0-9a-zA-Z]"); if (!sFirstChar.match(pattern)) { alert("Please correct the e-mail address. The first character must be a letter or number."); return false; } if (!sLastChar.match(pattern)) { alert("Please correct the e-mail address. The last character must be a letter or number."); return false; } if (iLength < 5) { alert("Please correct the e-mail address. It should conform to name@aaa.bbb"); return false; } var validchars = new String("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_@"); for (i=0; i