Date VerificationFunction isdate (STR) {var strseparator = "-"; // Date delimiter var strdatearray; var intyear; var intmonth; var intday; var boolleapyear; var strdate; strdate = STR; strdatearray = strdate. split (strseparator); // extract the IF (strdatearray. length! = 3) {alert ("the date you entered is incorrect"); Return "false";} intyear = parseint (strdatearray [0], 10 ); intmonth = parseint (strdatearray [1], 10); intday = parseint (strdatearray [2], 10); If (isnan (intyear) | isnan (intmonth) | isnan (intday) {alert ("your input date error"); Return "false";} If (intmonth> 12 | intmonth <1) {alert ("date error, the month must be a number between 0 and 12"); Return "false ";} if (intmonth = 1 | intmonth = 3 | intmonth = 5 | intmonth = 7 | intmonth = 8 | intm Onth = 10 | intmonth = 12) & (intday> 31 | intday <1) {alert ("date error, the day of the month you entered must be between 1-31 "); Return" false ";} if (intmonth = 4 | intmonth = 6 | intmonth = 9 | intmonth = 11) & (intday> 30 | intday <1 )) {alert ("date error, the day of the month you entered must be between 1-30"); Return "false" ;}if (intmonth = 2) {If (intday <1) {alert ("date error, month cannot be zero or null"); Return "false" ;}boolleapyear = false; if (intyear % 400 = 0) | (intyear % 4 = 0 & intyear % 100! = 0) // determine the leap year boolleapyear = true; else boolleapyear = false; // If (boolleapyear) {If (intday> 29) {alert ("date error, the day of March February of a leap year must be between 1 and 29 "); Return" false ";}} else {If (intday> 28) {alert (" date error, the date of March must be between 1 and 28 "); Return" false ";}}return" true ";}
Date comparisonVaR rukua, rukub, rukuc, SCA, SCB, SCC, fir, SEC; FIR = document. form1.produce _ date. value. split ("-"); sec = document. form1.stock _ in_date.value.split ("-"); rukua = parseint (SEC [0]); rukub = parseint (SEC [1]); rukuc = parseint (SEC [2]); SCA = parseint (FIR [0]); SCB = parseint (FIR [1]); SCC = parseint (FIR [2]); If (SCA> rukua) {alert ("warehouse receiving date cannot be earlier than the production date"); document. form1.stock _ in_date.focus (); Return false;} If (SCA = rukua & SCB> rukub) {alert ("the database date cannot be earlier than the production date"); document. form1.stock _ in_date.focus (); Return false;} If (SCA = rukua & SCB = rukub & SCC> rukuc) {alert ("warehouse receiving date cannot be earlier than the production date"); document. form1.stock _ in_date.focus (); Return false ;}