In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to use regular expressions to implement an authentication interface. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
First of all, let me show you the effect picture:
The key code is as follows:
Examples user name enter password again enter mobile phone number birthday var p = false;function check1 () {var reg=/ ^ [a-zA-Z] [a-zA-Z0-9] {3jue 15} $/; var div1=document.getElementById ("div1"); if (! reg.test (document.form1.input1.value)) {div1 [XSS _ clean] = "user name must be 4-16 letters or numbers and start with a letter";} else {div1 [XSS _ clean] = "return true"; }} function check2 () {var reg=/ [a-zA-Z0-9] {4Jing 10} /; var div2=document.getElementById ("div2"); if (! reg.test (document.form1.input2.value)) {div2 [XSS _ clean] = "passwords can only consist of letters and numbers with a length of 4-10 characters";} else {div2 [XSS _ clean] = "√"; return true;}} function check3 () {var div3=document.getElementById ("div3") If (document.form1.input3.value==0) {div3 [XSS _ clean] = "Please enter the password again";} else if (document. Form1.input3.valueinvalid documentation. Form1.input2.value) {div3 [XSS _ clean] = "password inconsistency";} else {div3 [XSS _ clean] = "√"; return true;} function check4 () {var reg=/ ^\ d {6} $/; var div4=document.getElementById ("div4") If (! reg.test (document.form1.input4.value)) {div4 [XSS _ clean] = "Postal code must be 6 digits";} else {div4 [XSS _ clean] = "√"; return true;}} function check5 () {var reg=/ ^ 1\ d {10} $/; var div5=document.getElementById ("div5"); if (! reg.test (document.form1.input5.value)) {div5 [XSS _ clean] = "Mobile number must be 11 digits and start with 1" } else {div5 [XSS _ clean] = "√"; return true;}} function check6 () {var reg=/ ^ [a-zA-Z] [a-zA-Z0-9] + @ ([a-zA-Z0-9] +.) + (com | cn) $/; var div6=document.getElementById ("div6"); if (! reg.test (document.form1.input6.value)) {div6 [XSS _ clean] = "email address is not in this format";} else {div6 [XSS _ clean] = "√"; return true }} function check7 () {var reg=/ ^ (\ d {4})-(\ d {1Magne2})-(\ d {1Magne2}) $/; var div7=document.getElementById ("div7"); var arr=reg.exec (document.form1.input7.value); if (arr==null) {div7 [XSS _ clean] = "birthday format is in the form of 1980-05-12 or 1988-05-04";} else if (arr [1] 2016) {div7 [XSS _ clean] = "birthdays must be 1900-2014" } else if (arr [2] 12) {div7 [XSS _ clean] = "the month of birthday is between 01 and 12";} else if (arr [3] 31) {div7 [XSS _ clean] = "birthday must be between 01 and 31";} else {div7 [XSS _ clean] = "√"; p = true }} function sub () {if (check1 () = = true&&p==true&& check2 () = = true&&check3 () = = true&&check4 () = true&&check5 () = = true&&check6 () = = true) {alert ("Registration succeeded");} else {alert ("Registration failed, you still have information not filled in or does not conform to the format");}} Thank you for reading! This is the end of this article on "how to use regular expressions to achieve authentication interface". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.