// REGULAR EXPRESSION DECLARATIONS var reAlphanumeric = /^[#a-zA-Z0-9]+$/ var reWhitespace = /^\s+$/ var reAlphabetic = /^[a-zA-Z]+$/ var reInteger = /^\d+$/ var reEmail = /^.+\@.+\..+$/ function isEmpty(s) { return ((s == null) || (s.length == 0)) } function isWhitespace (s) { // Is s empty? return (isEmpty(s) || reWhitespace.test(s)); } function isAlphabetic (s) { var i; if (isEmpty(s)) if (isAlphabetic.arguments.length == 1) return true; else return (isAlphabetic.arguments[1] == true); else { return reAlphabetic.test(s) } } function isAlphanumeric (s) { var i; if (isEmpty(s)) if (isAlphanumeric.arguments.length == 1) return true; else return (isAlphanumeric.arguments[1] == true); else { return reAlphanumeric.test(s) } } function isEmail (s) { if (isEmpty(s)) if (isEmail.arguments.length == 1) return false; else return (isEmail.arguments[1] == true); else { return reEmail.test(s) } } function isInteger (s) { var i; if (isEmpty(s)) if (isInteger.arguments.length == 1) return true; else return (isInteger.arguments[1] == true); return reInteger.test(s) } function isUSPhoneNumber (s) { if (isEmpty(s)) if (isUSPhoneNumber.arguments.length == 1) return true; else return (isUSPhoneNumber.arguments[1] == true); return (isInteger(s) && s.length == 10) } function checkString (theField, emptyOK) { if ((emptyOK == true) && (isEmpty(theField.value))) return true; if (isWhitespace(theField.value)) { return false; } else return true; } function isSSN (s) { if (isEmpty(s)) if (isSSN.arguments.length == 1) return true; else return (isSSN.arguments[1] == true); return (isInteger(s) && s.length == 9); } function isZIPCode (s) { if (isEmpty(s)) if (isZIPCode.arguments.length == 1) return true; else return (isZIPCode.arguments[1]); return (isAlphanumeric(s) && ((s.length == 5) || (s.length == 6))) } function hasWhitespace (s) { return (s.match(/\s/)!=null); } function verifyPassword(f) { var strMsg; var strEmptyFields = ""; var strErrors = ""; if (isEmpty(f.strOldPassword.value)) strEmptyFields += "\tOld Password\n"; if (f.strNewPassword1.value.length<4) strErrors += "Password must be between at least 4 characters.\n"; if (f.strNewPassword1.value.length>20) strErrors += "Password must be between less than 20 characters.\n"; if (!isAlphanumeric(f.strNewPassword1.value)) strErrors += "Password must be alphanumeric.\n"; if (f.strNewPassword1.value != f.strNewPassword2.value) strErrors += "Passwords do not match.\n" if (!strEmptyFields && !strErrors) return true; strMsg = "_________________________________________________________\n\n"; strMsg += "Your password was not changed because of the following error(s).\n"; strMsg += "Please correct these error(s) and re-submit.\n"; strMsg += "_________________________________________________________\n\n"; if (strEmptyFields) { strMsg += "- The following required field(s) must be completed:\n" + strEmptyFields + "\n"; if(strErrors) strMsg += "\n"; } strMsg += strErrors; alert(strMsg); return false; }