/* -------------- * // *** DHTML date validation script. courtesy of smartwebby.com (http://www.smartwebby.com/dhtml/) * // declaring valid date character, minimum year and maximum yearvar dtch = "/"; var minyear = 1900; var maxyear = 2100; function isinteger (s) {var I; for (I = 0; I <S. length; I ++) {// check that current character is number. vaR c = S. charat (I); If (C <"0") | (C> "9") return false ;} // All characters are numbers. return true;} function stripcharsinbag (S, bag) {var I; var returnstring = ""; // search through string's characters one by one. // If character is not in bag, append to returnstring. for (I = 0; I <S. length; I ++) {var c = S. charat (I); If (bag. indexof (c) =-1) returnstring + = C;} return returnstring;} function daysinfebruary (year) {// February has 29 days in any ye Ar evenly divisible by four, // minute t for Centurial years which are not also divisible by 400. Return (Year % 4 = 0 )&&((! (Year % 100 = 0) | (Year % 400 = 0 )))? 29: 28);} function daysarray (n) {for (VAR I = 1; I <= N; I ++) {This [I] = 31 if (I = 4 | I = 6 | I = 9 | I = 11) {This [I] = 30} if (I = 2) {This [I] = 29} return this} function isdate (dtstr) {var daysinmonth = daysarray (12) vaR pos1 = dtstr. indexof (dtch) var pos2 = dtstr. indexof (dtch, pos1 + 1) var strmonth = dtstr. substring (0, pos1) var strday = dtstr. substring (pos1 + 1, pos2) var stryear = dtstr. substring (pos2 + 1) Stryr = stryear if (strday. charat (0) = "0" & strday. length> 1) strday = strday. substring (1) if (strmonth. charat (0) = "0" & strmonth. length> 1) strmonth = strmonth. substring (1) for (VAR I = 1; I <= 3; I ++) {If (stryr. charat (0) = "0" & stryr. length> 1) stryr = stryr. substring (1)} month = parseint (strmonth) Day = parseint (strday) year = parseint (stryr) if (pos1 =-1 | pos2 =-1) {alert ("the date format shocould be: Mm/DD/YYYY ") return false} If (strmonth. length <1 | month <1 | month> 12) {alert ("Please enter a valid month") return false} If (strday. length <1 | day <1 | day> 31 | (month = 2 & day> daysinfebruary (year) | day> daysinmonth [month]) {alert ("Please enter a valid day") return false} If (stryear. length! = 4 | year = 0 | year <minyear | year> maxyear) {alert ("Please enter a valid 4 digit year between" + minyear + "and" + maxyear) return false} If (dtstr. indexof (dtch, pos2 + 1 )! =-1 | isinteger (stripcharsinbag (dtstr, dtch) = false) {alert ("Please enter a valid date") return false} return true}