Regular Expressions (e-mail, mobile)

Source: Internet
Author: User

<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)

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.