function validateDATE(fieldVal) { // Begin // Checks for the following valid date formats: // DD/MM/YYYY DD-MM-YYYY // Also separates date into month, day, and year variables // var datePat = /^(\d{1,2})(\/)(\d{1,2})\2(\d{2})$/; var datePat = /^(\d{1,2})(\/)(\d{1,2})\2(\d{4})$/; /* ^^^^ Information about this string ^^^^ Ignore first and last '/' it is code for RegExp Anything between () will be matched and remembered for later use ^ matches first input $ matches last input \ means that the next char after the '\' has a special meaning \2 means same thing as second operation in this case its : (\/|-) d means digit, it matches a number from 0 to 9 {n,m] = matches at least N and at most M occurences. N & M are assumed to be positive */ var matchArray = fieldVal.match(datePat); // is the format ok? if (matchArray == null) { errMsg ='Date is not in a valid format.\nUse the MM/DD/YYYY format' return false; } month = matchArray[1]; // parse date into variables day = matchArray[3]; year = matchArray[4]; // check month range if (month < 1 || month > 12) { errMsg ='Month must be between 1 and 12.' return false; } if (day < 1 || day > 31) { errMsg ='Day must be between 1 and 31.' return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { errMsg ="Month "+month+" doesn't have 31 days!" return false } // check for february 29th if (month == 2) { var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day>29 || (day==29 && !isleap)) { errMsg = "February " + year + " doesn't have " + day + " days!"; return false; } } return true; // date is valid } function trim(inputString) { // Removes leading and trailing spaces from the passed string. Also removes // consecutive spaces and replaces it with one space. If something besides // a string is passed in (null, custom object, etc.) then return the input. if (typeof inputString != "string") { return inputString; } var retValue = inputString; var ch = retValue.substring(0, 1); while (ch == " ") { // Check for spaces at the beginning of the string retValue = retValue.substring(1, retValue.length); ch = retValue.substring(0, 1); } ch = retValue.substring(retValue.length-1, retValue.length); while (ch == " ") { // Check for spaces at the end of the string retValue = retValue.substring(0, retValue.length-1); ch = retValue.substring(retValue.length-1, retValue.length); //} //while (retValue.indexOf(" ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string // retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings } return retValue; // Return the trimmed string back to the user } // Ends the "trim" function function IsZipUSA(field){ //validate zip var valid = "0123456789-"; var hyphencount = 0; if (field.length !=5 && field.length!=10) { //errMsg = "Please enter a 5 digit or 5 digit+4 zip code.\n\n (ie. 07407 or 07407-1338)" alert("Please enter a 5 digit or 5 digit+4 zip code.\n\n (ie. 07407 or 07407-1338)"); //field.focus(); return false; } for (var i=0; i < field.length; i++) { temp = "" + field.substring(i, i+1); if (temp == "-") hyphencount++; if (valid.indexOf(temp) == "-1") { //errMsg = "Invalid characters in zip code.\n\n (ie. 07407 or 07407-1338)" alert("Invalid characters in zip code.\n\n (ie. 07407 or 07407-1338)"); //field.focus(); return false; } if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) { //errMsg = "The hyphen should be used like this '07407-1338'. Please try again." alert("The hyphen should be used like this '07407-1338'. Please try again."); //field.focus(); return false; } } function isNumeric(s) { var rval = true var decimal = false if (s == "." || s == "") { rval = false } else { s = s.split("") for (c=0; c|'; var IsCorrect = true; for (var i=0; i < s.length; i++) { var c=s.charAt(i); if( valChar.indexOf(c) != -1 ) { IsCorrect = false; } } return IsCorrect; } function IsValidFolderChars(input){ return /^[^\\\/\:\*\?\x22\%\<\>\|]+$/.test(input) } function HasAtSign(s){ var valChar='@'; var IsCorrect = true; for (var i=0; i < s.length; i++) { var c=s.charAt(i); if( valChar.indexOf(c) != -1 ) { IsCorrect = false; } } return IsCorrect; } function validEmail(input) { return /^[^\s\x22\%]+@[^\s\'\x22\%]+\.\w\w\w?$/.test(input); } function IsStrMinLength(s,n){ var IsCorrect = true; if (s.length < n) { IsCorrect = false; } return IsCorrect; } function IsNumbers(s){ var valChar='0123456789'; var IsCorrect = true; for (var i=0; i < s.length; i++) { var c=s.charAt(i); if( valChar.indexOf(c) == -1 ) IsCorrect = false; } return IsCorrect; } //function XMultiSpaces(s){ /////ng // var ss; // ss = " "; // while (s.search(ss)) { // s = s.replace (" ", ss); // } // return s; //}