/*** Zip code ** STR: the string to be checked */string. Prototype. ispost = function () {If (! This. match (/^ \ W + (-\ W +) | (\. \ W +) * \ @ [A-Za-z0-9] + ((\. |-) [A-Za-z0-9] + )*\. [A-Za-z0-9] + $/) {return false;} return true;}/*** remove space * @ memberof {typename} * @ return {typename} */string. prototype. trim = function () {var M = This. match (/^ \ s * (\ s +) *) \ s * $/); Return (M = NULL )? "": M [1];}/*** is the mobile phone number * STR: the string to be checked */string. prototype. ismobile = function () {return (/^ (?: 13 \ d | 15 [89] | 18 \ d | 14 \ D )-? \ D {5} (\ D {3} | \ * {3}) $ /. test (this. trim ();}/*** whether it is a phone number * STR: the string to be checked * the phone number must have a zone number, which can contain a Location Number */string. prototype. istel = function () {return (/^ ([0 \ +] \ D {2, 3 }-)? (0 \ D {2, 3})-) (\ D {6, 8}) (-(\ D {3 ,}))? $ /. Test (this. trim ();}/*** only Chinese characters can be entered * @ memberof {typename} * @ return {typename} */string. prototype. ischinese = function () {var Re = new Regexp ("^ [\ u4e00-\ u9fa5] + $", ""); Return re. test (this. trim ();}/*** check whether it is a number. It can be a decimal number * @ return {typename} */string. prototype. isnumber = function () {If (! This) return false; var STRP =/^ \ D + (.)? (\ D + )? $/; Return STRP. test (this);}/*** is a valid QQ number * STR: the string to be checked */string. prototype. isqq = function () {If (/^ \ D {5, 9} $ /. test (this) {return true;} return false;}/*** is a valid IP * STR: the string to be checked */string. prototype. isip = function () {var Reg =/^ (25 [0-5] | 2 [0-4] [0-9] | [0-1] {1} [0-9] {2} | [1-9] {1} [0-9] {1} | [1-9]) \. (25 [0-5] | 2 [0-4] [0-9] | [0-1] {1} [0-9] {2} | [1- 9] {1} [0-9] {1} | [1-9] | 0) \. (25 [0-5] | 2 [0-4] [0-9] | [0-1] {1} [0-9] {2} | [1- 9] {1} [0-9] {1} | [1-9] | 0 )\. (25 [0-5] | 2 [0-4] [0-9] | [0-1] {1} [0-9] {2} | [1- 9] {1} [0-9] {1} | [0-9]) $/; If (Reg. test (this) {return true;} return false;}/*** is a valid date * STR: the string to be checked */string. prototype. isdate = function () {var Reg =/^ (1 [6-9] | [2-9] \ D) \ D {2})-(0? [1, 13578] | 1 [02])-(0? [1-9] | [12] \ d | 3 [01]) | (1 [6-9] | [2-9] \ D) \ D {2})-(0? [13456789] | 1 [012])-(0? [1-9] | [12] \ d | 30) | (1 [6-9] | [2-9] \ D) \ D {2 }) -0? 2-(0? [1-9] | 1 \ d | 2 [0-8]) | (1 [6-9] | [2-9] \ D) (0 [48] | [2468] [048] | [13579] [26]) | (16 | [2468] [048] | [3579] [26]) 00)-0? 2-29-) $/; If (Reg. Test (STR) {return true;} return false ;}
Call:
var str = ' qq ';var reslut = str.Trim();alert(reslut);//qq