$ (Function () {try {$. formvalidator. initconfig ({formid: "formtable", errorfocus: false, submitonce: True, tipstyle: "both", onerror: function () {// alert, an out-of-date callback function, cannot be verified ("the red prompt is invalid. Please modify it as prompted! ") ;}}); // Verification string (required) $ (" # name "). formvalidator ({// verification: Module name onshow: "(required)", onfocus: "(required) no more than 50 characters", oncorrect: "(correct) "}). inputvalidator ({min: 1, Max: 50, onerrormin: "(error) cannot be blank", onerrormax: "(error) cannot exceed 50 characters, the Chinese character is counted as two characters "}); // The verification string (optional) $ (" # name "). formvalidator ({// verification: Module name onshow: "(optional)", onfocus: "(optional) no more than 50 characters", oncorrect: "(correct)", empty: true }). inputvalidator ({min: 1, Max: 50, onerrormin: "(error) cannot be blank ", Onerrormax: "(error) no more than 50 characters. Chinese characters are counted as two characters"}); // verification time $ ("# adddate "). formvalidator ({// verification: sending time onshow: "(required)", onfocus: "(required) Select Operation Time", oncorrect: "(correct) "}). functionvalidator ({fun: function (Val, ELEM) {If (! /^ \ D {4}-\ D {2}-\ D {2} [] \ D {2}: \ D {2} $ /. test (VAL) {return "(error) Select Operation Time";} return true ;}}); // Ajax verification $ ("# account "). formvalidator ({// verification: Module name onshow: "(required)", onfocus: "(required) no more than 50 characters", oncorrect: "(correct) "}). inputvalidator ({min: 1, Max: 50, onerrormin: "(error) cannot be blank", onerrormax: "(error) cannot exceed 50 characters, the Chinese character is counted as two characters "}). ajaxvalidator ({type: "Post", URL: "isisemanage! Ajaxvalidatoruseraccount. action ", success: function (data) {If (Data =" 0 ") {return true;} else if (Data =" 1 ") {return false ;}}, onerror: "This account is in use. Please change it! "}); // Password and repeated password verification $ (" # password "). formvalidator ({// verification: Module name onshow: "(required)", onfocus: "(required) no more than 11 characters", oncorrect: "(correct) "}). inputvalidator ({min: 1, Max: 50, onerrormin: "(error) cannot be blank", onerrormax: "(error) cannot exceed 11 characters, the Chinese character is counted as two characters "}); $ (" # passwordrepeat "). formvalidator ({onshow: "(required)", onfocus: "(required) The two passwords must be consistent", oncorrect: "(correct )"}). comparevalidator ({Desid: "password", operateor: "=", onerror: "(error) two different passwords. Please confirm "}); // Image format verification $ ("# tccodelogo "). formvalidator ({onshow: "(optional)", onfocus: "(optional) Upload the image file", oncorrect: "(correct)", empty: true }). regexvalidator ({Regexp: regexenum. picture, onerror: "Only image files can be uploaded"}); // value verification $ ("# namenum "). formvalidator ({// verification: Module name onshow: "(required)", onfocus: "(required) value: 1 to 50", oncorrect: "(correct) "}). inputvalidator ({min: 1, Max: 50, type: "value", onerrormin: "(error) cannot be blank", onerrormax: "(error) value: 1 to 50 "}); // phone Verification $ ("# Linkphone "). formvalidator ({onshow: "(optional)", onfocus: "(optional)", oncorrect: "(correct)", empty: true }). regexvalidator ({Regexp: "^ (\ D {3, 4 }-? \ D {} | (13 | 15 | 18) \ D {9}) $ ", onerror:" (error) Incorrect phone number format, check "}); // email verification $ (" # linkemail "). formvalidator ({onshow: "(optional)", onfocus: "(optional) Please select the correct email format", oncorrect: "(correct)", empty: true }). regexvalidator ({Regexp: regexenum. email, onerror: "(error) Incorrect email format, please check"}); // select verification $ ("# testselect "). formvalidator ({onshow: "(required)", onfocus: "(required) select the option", oncorrect: "(correct )"}). inputvalidator ({min: 0, // start indexing onerro R: "Have you forgotten your degree! "}); // When hidden, $ (" # smsproductname ") is verified by default "). formvalidator ({// verify onshow: "(required)", onfocus: "(required) no more than 50 characters. The Chinese character is counted as two characters", oncorrect: "(correct) "}). functionvalidator ({fun: function (Val, ELEM) {if ($ ("# smsproductname "). is (": hidden") {return true;} If (! /^ \ S {1, 50} $ /. test (VAL) {return "(error) cannot exceed 50 characters. The Chinese character is counted as two characters";} return true ;}}); // The verification method of the multiple choice box is a little complicated $ (": checkbox [name = 'producttype']"). formvalidator ({onshow: "(select at least one)", onfocus: "(select at least one)", oncorrect: "(correct )"}). functionvalidator ({fun: function (Val, ELEM) {var objs =$ (": checkbox [name = 'producttype']"); For (VAR I = 0; I <objs. length; I ++) {if ($ (objs [I]). ATTR ("checked") = true) {$ ('# producttypetip '). removeclass (); $ ('# producttypetip '). addclass ("onsuccess"); Certificate ('your producttypetip'0000.html (); Certificate ('your producttypetip'0000.html ("<nobr> correct </nobr>"); Return true ;}}$ ('# producttypetip '). removeclass (); $ ('# producttypetip '). addclass ("onerror"); optional ('your producttypetip'{.html ("<nobr> (at least one choice) </nobr>"); Return false ;}});} catch (e) {alert (e );}});
Huodijin
Source: http://yelaiju.cnblogs.com
Some verification instances of formvalidator