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!