Use CSS and HTML to write a basic Web Framework
$. Metadata. setType ("attr", "vld"); $. validator. addMethod ("username", function (value) {var p =/^ [0-9a-zA-Z \ u4e00-\ u9fa5 \. \-@ _] + $/; return p.exe c (value )? True: false;}, "Please enter only letters, digits, chinese and '_', '-', '@'"); $. metadata. setType ("attr", "vld"); $. validator. addMethod ("username", function (value) {var p =/^ [0-9a-zA-Z \ u4e00-\ u9fa5 \. \-@ _] + $/; return p.exe c (value )? True: false;}, "Only letters, numbers, Chinese characters, '_', '-', '@' symbols can be entered"); jQuery. validator. addMethod ("isMobile", function (value, element) {var length = value. length; var mobile =/^ (0 | 86 | 17951 )? (13 [0-9] | 15 [012356789] | 17 [678] | 18 [0-9] | 14 [57]) [0-9] {8} $/; return this. optional (element) | mobile. test (value) ;}, "Enter your mobile phone number correctly"); jQuery. validator. addMethod ("isTel", function (value, element) {var length = value. length; var tel =/^ (0 \ d {2, 3})-) (\ d {7, 8}) (-(\ d {3 ,}))? $/; Return this. optional (element) | tel. test (value) ;}, "Enter your landline number correctly"); jQuery. validator. addMethod ("isPhone", function (value, element) {var length = value. length; var mobile =/^ (0 | 86 | 17951 )? (13 [0-9] | 15 [012356789] | 17 [678] | 18 [0-9] | 14 [57]) [0-9] {8 }$/; var tel =/^ (0 \ d {2, 3})-) (\ d {7, 8 }) (-(\ d {3 ,}))? $/; Return this. optional (element) | (tel. test (value) | mobile. test (value) ;}, "Please enter your contact number correctly"); jQuery. validator. addMethod ("isIdCardNo", function (value, element) {var length = value. length; // *** Regular Expression (15 bits) var isIDCard1 =/^ [1-9] \ d {7} (0 \ d) | (1 [0-2]) ([0 | 1 | 2] \ d) | 3 [0-1]) \ d {2} (\ d | X | x) $/; // *** Regular Expression (18 bits) var isIDCard2 =/^ [1-9] \ d {5} [1-9] \ d {3} (0 \ d) | (1 [0-2]) ([0 | 1 | 2] \ d) | 3 [0-1]) \ d {3} (\ d | X | x) $/; return this. optio Nal (element) | (isIDCard1.test (value) | isIDCard2.test (value) ;}, "Please enter your *** number correctly"); jQuery. validator. addMethod ("isZipCode", function (value, element) {var length = value. length; var zipCode =/^ [1-9] {1} (\ d +) {5} $/; return this. optional (element) | zipCode. test (value) ;}, "Please enter your zip code correctly"); jQuery. validator. addMethod ("isEmail", function (value, element) {var mail =/^ [a-z0-9. _ %-] + @ ([a-z0-9-] + \.) + [a-z] {2, 4} $/; return this. optional (element) | (mail. test (value) ;}, "wrong mailbox format"); <form class = "form b-mar-b-20" id = "VipApply_AddForm" action = "/addVipApply. jspx "> <span class =" form-item-name "> User name <span class =" c-red "> * </span> <input type =" text "class =" input-text "id =" loginName "name =" loginName "vld =" {required: true, rangelength: [3, 20], username: true, messages: {required: 'Enter the user name', rangelength: 'the user name consists of 3 to 14 characters in Chinese, English letters and numbers '}}"/> </form> $ ("# VipApply_AddForm "). validate ({submitHandler: function (form) {// callback after passing $. post ("$ {base}/addVipApply. jspx ", $ ('# VipApply_AddForm '). serialize (), function (data) {if (data. status = 0) {alert ("the VIP application has been submitted. Please wait for the review result! "); Location. href = '$ {base}/hymsa/';} else if (data. status = 1) {alert ("Verification code error"); $ ("# vipApplyCaptcha "). click () ;}, 'json') ;}, invalidHandler: function (form, validator) {// return false if callback fails ;}});}); @ RequestMapping (value = "**/addVipApply. jspx ") public void addVipApply (VipApplyEntity entity, String captcha, HttpServletRequest request, HttpServletResponse response, ModelMap model) throws JSONException {JSONObject json = new JSONObject (); try {this. vipApplyService. save (entity); json. put ("status", 0);} catch (Exception e) {json. put ("status", 1); e. printStackTrace ();} ResponseUtils. renderJson (response, json. toString ());}