JavaScript technology often used in BS development

xiaoxiao2021-03-06  49

http://search.9cbs.net/expert/topic/2489/2489689.xml?temp=.7334406

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. For example (2003-05, or 2003-5) 2.5 Only hours and minutes, shaped (12:03) 3, the value of all forms 3.1 All forms cannot be empty 3.2 Multi-line text box cannot be empty. 3.3 Multi-line text boxes The value cannot exceed SMAXSTRLENG 3.4 Multi-line text boxes cannot be less than SMIXSTRLENG 3.5 judge whether the radio box is selected.

3.6 Decision check box is selected. 3.7 Collection, multi-selection, unchecked, reverse selection 3.8 file Upload During the process of determining the file type 4, the character class 4.1 judgment character is composed of AZ or AZ. 4.2 The judgment character consists of letters and numbers. 4.3 Judgment Character consists of letters and numbers, underscore, and points. And the beginning can only be underscore and letters / ^ ([A-ZA-Z_] {1}) ([/ w] *) $ / G.Test ( STR) 4.4 String Replacement Function .Replace (); 5, Browser class 5.1 Judging the type of browser Window.navigator.Appname 5.2 Judging the version of IE WINDOW.NAVIGATOR.AppVersion 5.3 Judging the resolution of the client Window.screen.Height; WINDOW.SCREEN.WIDTH; 6, the judgment of the class 6.1 Email.

Function ismail (mail) {return (new regexp (/ ^ / w ) | (/ w )) * / @ [A-ZA-Z0-9] (/. | -) [ A-ZA-Z0-9] ) * /. [A-ZA-Z0-9] $ /). TEST (MAIL));} 6.2 Verification of mobile phone number 6.3 identity card Verification Function isidcardNo (NUM) { IF (ISNAN (NUM)) {Alert ("Input is not a number!"); RETURN FALSE;} var len = Num.length, Re; if (len == 15) RE = new regexp (/ ^ (/ ^ 6}) ()? (/ D {2}) (/ d {2}) (/ d {2}) $ /); Else IF (len == 18) Re = New Regexp (/ ^ (/ d {6}) () (/ d {4}) (/ d {2}) (/ D {3}) (/ d) $ /); ELSE {ALERT ("The number of digits entered!"); return false;} var A = Num.match (re); if (a! = null) {if (len == 15) {var D = new date "19" a [3] "/" a [4] "/" a [5]); var b = d.Getyear () == a [3] && (d.getMonth () 1) == a [4] && d.getdate () == a [5];} else {var d = new date (a [3] "/" a [4] "/" a [5 ]); Var b = d.Getfullyear () == a [3] && (d.getMOnth () 1) == a [4] && d.getdate () == a [5];} if (! B) ) {Alert ("Enter ID" A [0] "Birthday is not right! "); return false;}} Return true;} 3.7 checkbox, multi-selection, unchecked, reverse selection