JavaScript Verify that the client submitted the data [转]

xiaoxiao2021-03-05  55

Update made in August [Reply]

/ * File Name: Validate_form.js Function Name: ValidateForm Function: Verify Submitted Form Call Method: , Parameter length Unlimited variable interpretation : variable name meaning i, j loop counter variable vc_min, vc_max minimum, maximum vObjvalidate object, the object to be verified vTypevalidate type, the type of authentication vConvalidate condition, a verification condition eNumerror number, the number of errors eMsgerror message, the error message cItemNumchecked item number, select The number of items in the project, eventually displayed to the user's error message, the regular expression, the regular expression verification type: Code Meaning FitRegex must fully match "User-defined regular expression" AntireGex can't appear "matches user-defined regular expressions String "Notblank Does Keep ISNUMERIC Digital ISINT integer ISEMAIL mail address isplaintext plain text, can not include HTML code LengthRange Character length range NumericRange Digital size range ISEQUALTO confirmation item (such as password) and the first time I entered whether the first checklimit check how many items SelectValid Select a valid item: 健祥, chin @ blogchina.com Last Editor: September 24, 2004 * / Function Validateform () {Var i, j, vobj, vtype, vcon, enum = 0, EMSG = ', CITEMNUM = 0, Ferrmsg = '', Re; var args = validateform.Arguments; for (i = 0; i <(args.length-2); i = 3) {vobj = args [i]; vtype = args [i 1]; vcon = args [i 2]; switch (vty) {case 'FitRegex': re = vcon; if (Vobj.Value.Search (re)! = 0) {ENUM ; E Msg = generrmsg (Enum, Vobj, 'does not meet the requirements');} Break; case 'antiregex': re = vcon; if (Vobj.Value.Search (re)> = 0) {ENUM ; EMSG = generrmsg (Enum, Vobj, 'does not meet the requirements');} Break; Case 'notblank': if (Vobj.Value == ') {ENUM ; EMSG = generrmsg (enum, vobj,' Did not fill in ');} Break; case' isnumeric ': if (ISNAN (Vobj.Value) │ {ENUM ; EMSG = generrmsg (enum, vobj,' is not a number ') } Break;

Case 'Isint': RE = / ^ [0-9] $ /; if (Vobj.Value.Search (re)! = 0 ││ vobj.value.substring (0, 1) == 0) {ENUM ; EMSG = generrmsg (enum, vobj, 'is not integer');} Break; case 'iesmail': re = / ^ [a-za-z0-9 _] @ [a-za-z0-9 _] /. [-za-z0-9_] or above/8 (re)! = 0) {ENUM ; EMSG = generrmsg (enum, vobj, 'is not a valid email address') } Break; Case 'IsPlainText': RE = / <[A-ZA-Z] [^>] *> /; if (Vobj.Value.Search (Re)> = 0) {ENUM ; EMSG = generrmsg (Enum, Vobj, 'is not plain text, containing HTML tag');} Break; case 'length': vc_min = parsefloat (vcon.substring (0, vcon.indexof ("to")))))); vc_max = parsefloat (vcon.substring (vcon.indexof ("to") 2)); if (vobj.value.Length vc_max) {ENUM ; EMSG = generrmsg (Enum, Vobj The length of 'is not in the specified range');} Break; Case 'NumericRange': vc_min = parsefloat (vcon.substring (0, vcon.indexof ("to")))))); vc_max = parsefloat (vcon.substring. IndexOf ("to") 2)); if (vobj.value vc_max) {Enum ; EMSG = generrmsg (Enum, Vobj, 'is not within the specified range "); } Break; Case 'ISEQUALTO': IF (Vobj.Valu e! = vcon.value) {ENUM ; EMSG = generrmsg (Enum, Vobj, 'and the first input ");} Break; Case' Checklimit ': VC_MIN = PARSEFLOAT (vcon.substring (0 Vcon.indexof ("to"))))))))))))); vc_max = parsefloat (vcon.sustring (vcon.indexof ("to") 2); if (vc_max == -1) // vc_max = -1 indicates no upper limit {vc_max = vobj.length;} for (j = 0; j

) {IF (Vobj [J] .checked) {CItemNum ;}}} f (CItemnum

转载请注明原文地址:https://www.9cbs.com/read-34533.html

New Post(0)