http://www.microsoft.com/china/technet/security/guidance/secmod83.mspx
Table 10.2: Common regular expression fields
Field Expression Format Example Description Name [A-ZA-Z'`-'/ s] {1,40} John DoEO'Dell verification name. Up to 40 uppercase letters and lowercase letters, as well as special characters commonly used in the name. This list can be adjusted. Digital ^ / d? (/ D {3}) / d? / D? (/ D {3}) / d? (/ D {4}) $ (425) -555-0123425-555-0123425 555 0123 Verification US phone number. Email / W ([- .]/w ) *@/w ([-.]/w "**/w ([-.]/w )*osomeone@example.com Verify the email address. URL ^ (HTTP | HTTPS | FTP) /: // [A-ZA-ZA0-9 / - /.] /. [A-ZA-Z] {2,3} (: [A-ZA-Z0- 9] *)? /? ([A-ZA-Z0-9 /-/._/?, $ $ $ /. "* $ = ~ ~]) * $ Verify the URL. Postal Coding ^ (/ D {5} - / D {4} | / d {5} | / d {9}) $ | ^ ([A-ZA-Z] / D [A-ZA-Z] / D [A-ZA-Z] / D) $ Verification Allows US Postal Codes for 5 or 9 numbers. Password ^ (? =. * / D) (? =. * [A-z]) (? =. * [A-z]). {8, 10} $ Verify strong password. The number of characters must be within 8 to 10. You must contain a combination of case letters and numbers, and special characters cannot be used. Non-negative integer / d 0986 verify an integer greater than zero. Currency (non-negative) "/ d (/ d)?" Verify the positive monetary amount. There are two digits after the decimal point. Currency (positive or negative) "(-)? / D (/./ D / D)?" Verify the positive and negative monetary amount. There are two digits after the decimal point.
"" "" "" "" "" "" "" "
Use the regular expression to limit the text box in the text box in the web form:
Use the regular expression restrictions can only be entered in Chinese: οNKEYUP = "value = value.replace (/ [^ / U4E00- / U9FA5] / g, '')" onbeforepaste = "ClipboardData.SetData ('Text', ClipboardData.Getdata) 'Text'). Replace (/ [^ / U4E00- / U9FA5] / g, '')) "
Use the regular expression to limit only full-width characters: οnkeyup = "value = value.replace (/ [^ / uff00- / uffff) / g, ')" onbeforepaste = "clipboardData.setdata (' Text ', ClipboardData.Getdata) ('text'). Replace (/ [^ / UFF00- / UFFFFF] / g, '')) "
Use regular expressions to limit only numbers: οnkeyup = "value = value.replace (/ [^ / d] / g, '')" onbeforepaste = "ClipboardData.SetData ('Text', ClipboardData.Getdata ('Text' ) .Replace (/ [^ / d] / g, '')) "Use regular expressions to limit only numbers and English: οNKEYUP =" value = value.replace (/ [/ w] / g, '') "Onbeforepaste =" ClipboardData.SetData ('Text', ClipboardData.GetData ('Text'). Replace (/ [^ / D] / g, '') ")"
"" "" "" "" "" "" "" "
telephone number
date
Digital, score
"" "" "" "" "" "" "" "
http://www.romanfr.com/weblog/archives/125-Yoiae.html
First, the verification class 1, the digital verification is 1.1 integer / ^ (│ )? D $ / can not be empty / ^ [- ]? D * $ / can be an integer of 1.2 greater than 0 (for transmission The verification of IDs) / ^ D $ / 1.3 negative integers /^-d $ 11.4 integer cannot be greater than IMAX can be written according to the top of the above. 1.5 Integers cannot be written in less than IMIN according to the top of the above. 2, time class 2.1 short time, shaped (13:04:06) Function istime (str) {var a = str.match (/ ^ (d) ((D) 2 (d) $ /); if ( a == null) {Alert ('input parameter is not time format'); return false;} if (a [1]> 24 ││ a [3]> 60 ││ a [4]> 60) {Alert "Time format is wrong"; return false} return true;} 2.2 short date, shaped (2003-12-05) Function strdatetime (str) {var r = str.match (/ ^ (D) (- │ /) ( d) 2 (d) $ /); 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, shape (2003-12-05 13) : 04: 06) Function StrdateTime (STR) {var REG = / ^ (d) (│ /) (d) 2 (d) D) d) $ /; var r.match (reg) ; if (r == null) Return False; var D = new 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 3.2 Multi-line text boxes cannot be empty.
3.3 Multi-line text boxes You cannot exceed the SMAXSTRLENG // Test text box, whether the content is long function checktextArelength (VAL, max_length) {var str_area = document.forms [0] .Elements [Val] .value; if (str_area! = Null && str_Area.length> max_length) {alert ("field text is long, up to" max_length "characters, please re-enter!"; Document.Forms [0] .Elements [Val] .focus (); document. Forms [0] .Elements [Val] .Select (); return false;} Return true;} 3.4 Multi-line text boxes cannot be less than SMIXSTRLENG3.5 judgment radio box is selected.
Function Checkradio (Val, MSG1, MSG2) {var is_radio = document.forms [0] .Elements [Val]; var s_msg1 = (msg1 == NULL ││ MSG1 == ""? "Please select Radio!": msg1; VAR S_MSG2 = (MSG2 == NULL ││ MSG2 == "" "" No optional Radio! ": msg2; if (is_radio) {if (Document.Forms [0] .Elements [Val] .Value! = null {IF (Document.Forms [0] .Elements [Val] .checked {Return True;} else {Alert (S_MSG1); Return False;}} else {var check_length = document.form [0] .Elements [VAL ] .length; var i_count = 0for (var i = 0; I