The regular expression verifies the ID card number and email address, determines the checked selected status, and the regular expression checked

Source: Internet
Author: User

The regular expression verifies the ID card number and email address, determines the checked selected status, and the regular expression checked

The project is well written to login registration. When the blur event is used to verify user input content, a bug occurs. Finally, the user input value is obtained in the onclick event of the Registration button for verification.

Determine the checked selection status:

If (! $ ('# CheckedAgree '). prop ("checked") {console. log ('no'); // unselected} else {console. log ('yes'); // select} // register $ (". regBtn "). on ('click', function () {var regUser = $ ('# reguser '). val (); // user name var regPass =$ ('# regPass '). val (); // password var regAgainpass = $ ('# regagainpass '). val (); // confirm the password var regTrueName = $ ('# regTrueName '). val (); // real name var idNumber = $ ('# idNumber '). val (); // ID card var email =$ ('# email '). val (); // email if (! RegUser) {alert ("the user name is blank. Enter the user name");} else if (! RegPass | regPass. length <6) {alert ("the password is empty or has less than 6 characters. Please enter the correct password");} else if (! RegAgainpass | regAgainpass! = RegPass) {alert ("confirm that the password is blank or the two passwords are inconsistent. Please enter the correct password");} else if (! RegTrueName) {alert ("real name is blank, please enter real name");} else if (! IdNumber |! IdNum (idNumber) {// call the ID card verification method alert ("Incorrect ID card number, please enter the correct ID card number");} else if (! Email |! EmailNum (email) {// call the email address verification method alert ("Incorrect email address, please enter the correct email address");} else if (! $ ('# CheckedAgree '). prop ("checked") {// judge the user's consent to the Registration Agreement Status alert ("You have not yet agreed to the User Registration Agreement");} else {console. log ('yes'); // some code here}); // ID number verification function idNum (idNum) {var reg =/(^ \ d {15} $) | (^ \ d {18} $) | (^ \ d {17} (\ d | X | x) $)/; if (! Reg. test (idNum) {return false;} else {return true ;}// function emailNum (emailNum) {var reg =/^ ([a-zA-Z0-9 _-]) + @ ([a-zA-Z0-9 _-]) + ((\. [a-zA-Z0-9 _-] {2, 3}) {1, 2}) $ // verify the ID card number if (! Reg. test (emailNum) {return false;} else {return true ;}}

The above section describes the regular expression used to verify the ID card number and email address and determine the checked selection status. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.