<form action= "#" method= "POST" onsubmit= "return Check ()" Name= "Regi" ></form>functionCheck () {//Email
Get form elements by name
varMail =Document.regi.mail.value; varMailreg = document.getElementById ("Reg-mail"); varRegularmail =/^\[email protected][a-z0-9]+\. [a-z]+$/i; if(regularmail.test (mail)) {mailreg.innerhtml= "The mailbox is formatted correctly!" ";//return;}Else{mailreg.innerhtml= "Bad mailbox format!" ";//return false; } //Mobile Phone varMobile =Document.regi.mobile.value; varMobilereg = document.getElementById ("Reg-mobile"); //The expression starts with 1, the second bit may be any one of the 3/4/5/7/8, and the next \d represents the 9 digits of the number [0-9], which adds up to a total of 11 digits. varRegularmobile =/^1 (3|4|5|7|8) \d{9}$/; if(Regularmobile.test (mobile)) {mobilereg.innerhtml= "The phone number is correct!" ";//return;}Else{mobilereg.innerhtml= "The phone number is wrong!" ";//return false; }}
Regular Expressions (e-mail, mobile)