Web page input judgment function

xiaoxiao2021-03-06  50

// Filter illegal character function string.Prototype.trim () {return this.Replace (/ (^ / s *) | (/ s * $) / g, "");} // can only enter the correct date format Function isdate (s, msg) {if (s.Value.Length == 0) Return true; if (! msg) MSG = 'Please enter the correct date format, for example 2003-05-06'; var str = s. Value var rag = / ^ (/ d {4}) (- | //) (0? [1-9] | 1 [0-2]) (- | //) (0? [1-9] | [12] [0-9] | 3 [01]) $ / g; var R = reg.exec (str); if (r == null) {Alert (msg); s.SELECT (); returnaf } Var D = new date (r [1], r [3] -1, r [5]); var newstr = d.Getfullyear () r [2] (d.getMonth () 1) r [2] D.Getdate () VAR REG = / (/ / | -) (0 *) (*) ([1-9]) / g var t = s.Value.Replace (Reg, '$ 1 $ 4 " IF (newstr == t) {return true;} s.focus (); s.select (); Alert (msg); Return False;} // can only enter standard E-MAIL mail format Function Isemail (S , MSG) {if (s.Value.Length == 0) Return true; var REG = / ^ ([AZ]) {1,} ([/. A-Z0-9 _ / -]) {1,} [A-Z0-9]) {1,} @ ([A-Z0-9_-]) {3,} (/. ([A-Z0-9]) {2,4}) {1,2} $ / GI; if (Reg.Test (S.Value)) Return True; Else {Alert ((msg? msg: 'Please enter the standard E-MAIL mail format, such as Test@163.net'); s. Focus (); s.select () Return false;}} // can only enter English Function Isenglish (S, MSG) {var REG = / ^ [AZ] * $ / GI if (Reg.Test (S.VA LuE)) RETURN TRUE ELSE {ALERT ((MSG? msg: 'This bar can only enter English, please correct')); s.focus (); s.select (); return false;}} // can only enter Chinese Function ischinese (s, msg) {var REG = / [^ / U4E00- / U9FA5] / g; if (reg.test (s.Value)) {s.focus (); s.select () Alert (() MSG? msg: 'This bar can only enter Chinese, please correct')); return false;} return true;} // cannot enter Chinese Function ISNOCHINESE (S, MSG) {var REG = / [/ u4E00- / u9fa5] | [/ ufe30- / uffa0] / gi; if (reg.test (s.value)) {s.select () ALERT ((msg? msg: 'This column can't enter Chinese and full-width symbol, please correct')) Return false;}}} // Cannot be empty Function Iszero (S, MSG) {var str = S.Value.trim (); if (str.length! =

0) RETURN TRUE ELSE {ALERT ((MSG? MSG: 'This column cannot be empty, please correct')); s.focus (); s.select (); return false;}} // can only enter digital function ISNUMERIC (S, MSG) {if (S.Value * 1! = S.Value) {alert ((msg? msg: 'This bar can only enter digital, please correct')) S.focus (); s, S.SELECT () Return False} Return true} // can only enter English and digital Function Isen (S, MSG) {var REG = / ^ [A-Z0-9.] * $ / GI if (Reg.Test (S.Test (S.Value )) RETURN TRUE ELSE {ALERT ((MSG? MSG: 'This bar can only enter English and numbers, please correct'); s.focus (); s.select (); return false;}} // function interface function chkForm (frmName) {this.frmName = frmName; this.chkFunBody = "."; this.isPass = function (eleName, chkFun, strMsg) {this.chkFunBody = chkFun "(" this.frmName "" eleName IF (strmsg) this.chkfunbody = ", /" " strmsg " "" this.chkfunbody = ") &&" var TMP = "Return (" this.chkfunbody "true) EVAL (this.frmname ".οnsubmit = function ('" tmp ");");}}

function checkvalue (str) {var checkOK = "0123456789-,."; var checkStr = str; var allValid = true; var validGroups = true; var decPoints = 0; var allNum = ""; var countNumberAfterDot; var countYN;

Countyn = 0; countnumbefterdot = 0;

For (i = 0; i

IF (countyn == 1) {countNumBerafterDot ;}}

if (! allvalid) {alert ("can only enter digital characters."); return (false);}

IF (Decpoints> 1 ||! ValidGroups || CountNumBerafterDot> 3) {Alert ("Please enter a valid number."); return (false);}

IF (CHECKSTR> 9999999999999.99) {Alert ("The value you entered is too large, which will result in overflow errors."); return (false);} if (checkstr <-99999999999.99) {Alert ("You entered the value of the value, will Resulting in overflow errors. "); Return (false);

Return True;}

---- How to call