<SCRIPT src = "scripts/jquery-1.4.1.js" type = "text/JavaScript"> </SCRIPT> <script language = "JavaScript" type = "text/JavaScript"> /*** define the regular expression object */var regexs = {Email: (/^ [0-9a-z] [0-9a-z \-\ _ \.] + @ ([0-9a-z] [0-9a-z \-] * \.) + [A-Z] {2, }$/I), // email phone: (/^ 0 [0-9] {2, 3} [2-9] [0-9] {6, 7} $/), // landline mobile phone number ydphpne: (/^ (13 [4-9]) | (15 [012789]) | 147 | 182 | 187 | 188) [0-9] {8} $ /), // mobile phone number allphpne: (/^ (13 [0-9]) | (15 [0-9]) | (18 [0-9]) [0-9] {8} $/), // all mobile phone numbers ltphpne: (/^ (13 [0-2]) | (15 [56]) | (186) | (145) [0-9] {8 }$/), // China Unicom mobile phone number dxphpne: (/^ (133) | (153) | (180) | (189) [0-9] {8} $/), // China Telecom mobile phone number URL: (/^ http: \/([0-9a-z] [0-9a-z \-] * \.) + [A-Z] {2,} (: \ D + )? \/[0-9a-z % \-_ \/\.] +/I), // URL num: (/[^ 0-9]/), // number cnum: (/[^ 0-9a-za-z _. -]/), Photo :(/\. JPG $ | \. JPEG $ | \. GIF $/I), // image format row: (/\ n/ig)};/*** @ return returns true if it meets the corresponding format, otherwise, false */function chkformat (STR, FTYPE) {var nreg = regexs [FTYPE]; If (STR = NULL | STR = "") return false; // The input is null and is considered to pass if (FTYPE = 'num') {If (! Nreg. Test (STR )&&! Chkchinese (STR) {// 10.23 tenfy must be a number and cannot contain Chinese return true;} else {return false ;}} if (! Nreg. test (STR) {return true;} else {return false ;}}; function chkchinese (s) {for (VAR I = 0; I <S. length; I ++) {If (S. charcodeat (I)> 255) return true;} return false ;}; </SCRIPT> use the following: <input value = "" type = "text" id = "txt_val"/> <br/> <input value = "verify" type = "button" onclick = "Return chkformat ($ ('# txt_val '). val (), 'email ') "/>