JavaScript technology, often used in BS development 1

xiaoxiao2021-03-06  95

I. Verification class 1, digital verification 1.1 integer / ^ (-|/ ) 1.2 greater than 0 integers (used for ID authentication) / ^ / D $ / .test (STR) 1.3 negative integer verification / ^-/d //.test (STR) 2, time class 2.1 short time, shaped (13:04:06) Function istime (str) {var A = STR. Match (/ ^ (/ d {1, 2}) (:)? (/ d {1, 2}) / 2 (/ d {1, 2}) $ /); if (a == null) {Alert ('Enter parameters are not time format'); return false;} if (a [1]> 24 || a [3]> 60 || a [4]> 60) {Alert ("time format is not pair"); Return true;} 2.2 Short date, shaped (2003-12-05) Function strdatetime (STR) {var r = str.match (/ ^ (/ D {1, 4}) (- | //) (/ D {1, 2}) / 2 (/ d {1, 2}) $ /); if (r == null) Return False; var D = new date (r [1], r [3] - 1, R [4]); return (d.Getfullyear () == r [1] && (D.getMonth () 1) == r [3] && d.getdate () == r [4]); } 2.3 long, shaped (2003-12-05 13:04:06) Function strdatetime (STR) {var REG = / ^ (/ d {1, 4}) (- | //) (//) (/ D {1 2}) / 2 (/ d {1, 2}): (/ d {1, 2}): (/ d {1, 2}) $ /; var r = Str.match (reg); if (r == null) Return False; var D = ne W Date (R [1], R [3] -1, R [4], R [5], R [6], R [7]); return (d.Getfullyear () == r [1] && (D.GETMONTH () 1) == r [3] && D.getdate () == r [4] && D.GetHours () == R [5] && D.getminutes () == r [6] && D. Getseconds () == r [7]);} 2.4 only year and month. If (2003-05, or 2003-5) 2.5 is only hours and minutes, shaped (12:03) 3, the value of all forms of the form cannot be empty 4.2 Judgment character consists of letters and numbers. >>