Use CSS and HTML to write a basic Web Framework

Source: Internet
Author: User

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 ());}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.