Use JS Regular expression Verification mobile phone number, email address, zip code

Source: Internet
Author: User
Tags regular expression zip

  Use JS Regular expression to verify the phone number, email address, zip code. Need friends can come to the reference, I hope to help you.

Cell phone number verification (13 opening and 158,159 beginning, total 11 bits)   code as follows: Var re; var Ss=document.getelementbyid (' TextBox3 '). Value; Re=/^ (13[0-9]{9}) | (15[89][0-9]{8}) $/if (Re.test (ss))  {   document.getelementbyid (' Label3 '). innertext= "";  / Assign a value to a label using the innertext  } else { document.getelementbyid (' label3 '). innertext= "Please enter the correct mobile phone number!" ";  document.getelementbyid (' ImageButton1 '). Disabled=true; Disable button with disabled}   email address verification (contains @ and.) code as follows:   VAR re;   var Ss=document.getelementbyid (TEXTBOXID). value;   re=/w@w*.w/ if (re.test (ss))    document.getelementbyid (' Label4 '). innertext= "";  else  {   document.getelementbyid (' Label4 '). innertext= "Please enter the correct email address!" ";    document.getelementbyid (' ImageButton1 '). Disabled=true; &NBSP}   ZIP/Postal Code verification (beginning cannot be 0, total 6 bits)   code is as follows: Var Ss=document.getelementbyid (' TextBox4 '). Value; var re=/^[1-9][0-9]{5}$/if (re.test (ss))   document.getElementById (' Label5 '). innertext= ""; else {  Document.getelemeNtbyid (' Label5 '). Innertext= postal Code is not in the correct format! ";  }   var r=/^13[012345789]{9}/11 digits beginning with 13, after 9 digits 6  

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.