Mobile phone number verified by Jquery Validation plug-in

Source: Internet
Author: User

Mobile phone number verified by Jquery Validation plug-in
JQuery Validate plug-in Introduction

 

The jQuery Validate plug-in provides powerful form verification functions to simplify form verification on the client side. It also provides a large number of custom options to meet various application needs. This plug-in is bundled with a set of useful verification methods, including URL and email verification, and provides an API for Writing user-defined methods. All bundling methods use English as the error message by default and have been translated into 37 other languages.
This plug-in is composed of J? Rn Zaefferer was written and maintained. He is a member of the jQuery team, a major developer of the jQuery UI team, and a QUnit maintainer. This plug-in started to appear in early jQuery in 2006 and has been updated to date. The current version is 1.13.1 (as of: 2015.05.26 ).

Custom mobile phone number verification code

 

// Verify the jQuery mobile phone number. validator. addMethod ("isMobile", function (value, element) {var length = value. length; var mobile =/^ (13 [0-9] {9}) | (18 [0-9] {9 }) | (14 [0-9] {9}) | (17 [0-9] {9}) | (15 [0-9] {9}) $ /; return this. optional (element) | (length = 11 & mobile. test (value) ;}, "Please enter your mobile phone number correctly ");

 

Verification Form

 

 

$ ("# CheckPhoneForm "). validate ({rules: {phone: {required: true, minlength: 11, // custom method: Check whether the mobile phone number exists in the Database // checkPhoneExist: true, isMobile: true}, code: {digits: true, required: true }}, messages: {phone: {required: "Enter your mobile phone number", minlength: "Make sure that the mobile phone number cannot be less than 11 characters", isMobile: "Please enter your mobile phone number correctly"}, code: {required: "Please enter the verification code", digits: "Verification Code should enter a number" }}, errorPlacement: function (error, element) {error. appendTo (element. next (). next () ;}, ignore :". codeCls "});

 

HTML

 

 

 

 

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.