function IsNumeric(sText) { var ValidChars = "0123456789."; var IsNumber = true; var Char; var sawDot = false; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if(Char == '.'){ if(sawDot) return false else sawDot = true } if (ValidChars.indexOf(Char) == -1){ IsNumber = false; } } return IsNumber; } // ******************************************************** // This function accepts a string variable and verifies if // it is a proper date or not. It validates format // matching either mm-dd-yyyy or mm/dd/yyyy. Then it checks // to make sure the month has the proper number of days, // based on which month it is. // The function returns true if a valid date, false if not. // ******************************************************** function isDate(dateStr) { var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)((\d{2})|(\d{4}))$/; var matchArray = dateStr.match(datePat); // is format OK? if (matchArray == null) { return false; } // parse date into variables month = matchArray[1]; day = matchArray[3]; year = matchArray[5]; if (month < 1 || month > 12) { // check month range return false; } if (day < 1 || day > 31) { return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { return false; } if (month == 2) { // check for february 29th var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day > 29 || (day==29 && !isleap)) { return false; } } return true; // date is valid } function replace(string,text,by) { // Replaces text with by in string var strLength = string.length, txtLength = text.length; if ((strLength == 0) || (txtLength == 0)) return string; var i = string.indexOf(text); if ((!i) && (text != string.substring(0,txtLength))) return string; if (i == -1) return string; var newstr = string.substring(0,i) + by; if (i+txtLength < strLength) newstr += replace(string.substring(i+txtLength,strLength),text,by); return newstr; } function isValidEmail(strEmail){ validRegExp = /^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/i; if(strEmail.search(validRegExp) == -1) return false; return true; } function getXmlHttp(){ var xmlhttp = false; if(window.XMLHttpRequest){ xmlhttp = new XMLHttpRequest(); } else if(window.ActiveXObject){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(E){ xmlhttp = false; } } } return xmlhttp; }