Ife_part2_javascript_ Regular Expression usage (email/mobile number)

Source: Internet
Author: User

Determines whether the e-mail address//^ represents the beginning of the match//\w+  \w means matching an English letter or number, + means matching the preceding element one or more times/@  means matching the @ symbol//[a-z0-9]+  [a-z0-9] Represents a match letter A-Z or 0-9,+ that matches the preceding element one or more times//\.  Represents a.//[a-z]+ that matches any one of the letters A-Z, + means that matches the preceding element one or more times//{1,3} matches the contents of the  preceding parenthesis 1 times-3 times//$ to match the End Function Isemail (emailstr ) {    var emailreg =/^\[email protected][a-z0-9]+ (\.[ a-z]+) {1,3}$/;    if (Emailreg.test (EMAILSTR)) {        Console.log ("The email address you entered is in the correct format! ")        return true;    } else {        Console.log ("The email address you entered is not formatted correctly")        return false;    }} Determine whether the cell phone number//1 is the beginning of the first;//2--The second can be 3,4,5,7,8, any one of them;//3--ends with 9 integers of 0-9. function Isphone (phoneint) {    var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;      if (Myreg.test (Phoneint)) {        Console.log ("The phone number you entered is in the correct format! ")          return true;      } else {          Console.log ("The phone number you entered is not in the correct format! ")                  return false;      }  }

  

Ife_part2_javascript_ Regular Expression usage (email/mobile number)

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.