JavaScript helper Methods Series: (1) Use regular expressions to determine phone numbers and mailboxes

Source: Internet
Author: User


Determine if the mailbox

jquery verifies that the mailbox function Checksubmitemail () {if ($ ("#email"). val () = = "") {//$ ("#confirmMsg"). HTML ("<font color= ' Red ' & gt; e-mail address cannot be empty! </font> "); alert (" Mailbox cannot be empty! ") $ ("#email"). focus (); return false;} if (!$ ("#email"). Val (). Match (/^\w+ ((-\w+) | ( \.\w+)) *\@[a-za-z0-9]+ ((\.| -) [a-za-z0-9]+] *\. [a-za-z0-9]+$/) {alert ("Incorrect mailbox format");//$ ("#confirmMsg"). HTML ("<font color= ' Red ' > Mailbox format is incorrect!) Please re-enter! </font> "); $ (" #email "). focus (); return false;} return true;}


Determine if the phone number is

jquery verifies that the mobile number function Checksubmitmobil () {if ($ ("#mobile"). val () = = "") {alert ("mobile phone number cannot be empty!") ");//$ (" #moileMsg "). HTML (" <font color= ' red ' > Phone number cannot be empty! </font> "); $ (" #mobile "). focus (); return false;} if (!$ ("#mobile"). Val (). Match (/^ (((13[0-9]{1}) |159|153) +\d{8}) {alert ("cell phone number format is incorrect!) ");//$ (" #moileMsg "). HTML (" <font color= ' red ' > Phone number format incorrect!) Please re-enter! </font> "); $ (" #mobile "). focus (); return false;} return true;}






JavaScript helper Methods Series: (1) Use regular expressions to determine phone numbers and mailboxes

Related Article

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.