var EMAIL_ERROR_ALPHA_AND_DOT_MISSING = "Email address seems incorrect (check @ and .'s)"; var EMAIL_ERROR_INVALID_USERNAME = "This username contains invalid characters."; var EMAIL_ERROR_INVALID_DOMAIN = "This domain name contains invalid characters."; var EMAIL_ERROR_INVALID_IP = "Destination IP address is invalid!"; var EMAIL_ERROR_DOMAIN_DOT_COUNTRY = "The address must end in a well-known domain or two letter " + "country."; var EMAIL_ERROR_MISSING_HOSTNAME = " This address is missing a hostname!"; function emailCheck ( fieldValue ) { var emailStr = fieldValue; var errorString = ""; var checkTLD=1; var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/; var emailPat=/^(.+)@(.+)$/; var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]"; var validChars="\[^\\s" + specialChars + "\]"; var quotedUser="(\"[^\"]*\")"; var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/; var atom=validChars + '+'; var word="(" + atom + "|" + quotedUser + ")"; var userPat=new RegExp("^" + word + "(\\." + word + ")*$"); var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$"); var matchArray=emailStr.match(emailPat); if (matchArray==null) { errorString = EMAIL_ERROR_ALPHA_AND_DOT_MISSING; return errorString; } var user=matchArray[1]; var domain=matchArray[2]; for (i=0; i127) { errorString = EMAIL_ERROR_INVALID_USERNAME; return errorString; } } for (i=0; i127) { errorString = EMAIL_ERROR_INVALID_DOMAIN; return errorString; } } if (user.match(userPat)==null) { errorString = EMAIL_ERROR_INVALID_USERNAME; return errorString; } var IPArray=domain.match(ipDomainPat); if (IPArray!=null) { for (var i=1;i<=4;i++) { if (IPArray[i]>255) { errorString = EMAIL_ERROR_INVALID_IP; return errorString; } } return ""; } var atomPat=new RegExp("^" + atom + "$"); var domArr=domain.split("."); var len=domArr.length; for (i=0;i