Validation with regular expressions on the registration page (Js/aspx.cs)

Source: Internet
Author: User

1, verify the mailbox (user name)

JS page:first define variables and regularvarUsermail = $ ("#usermail"). Val (); var username=/^ ([a-za-z0-9_-]) [email protected] ([a-za-z0-9_-]) + (. [ A-za-z0-9_-]) +/; make judgments//Regular expression to determine the mailboxif(!username.test (Usermail)) {Alert ("Incorrect mailbox Format");} on the Aspx.cs page://Regular expression to determine whether the mailbox conforms tostringPat =@ "^ ([a-za-z0-9]|[. _]) [Email protected] ([a-za-z0-9_-]) + (\.[ A-za-z0-9_-]) + ";//Regular judgment MailboxRegexR =NewRegex(Pat,RegexOptions. IgnoreCase);Matchm = R.match (Usermail);if(!m.success) {Response.Write ("username");return; } (The following direct write regular expression)2. Verify the phone numbervarMobile =/^1[3|4|5|8][0-9]\d{4,8}$/;//Regular expression to determine the format of the phone number (only the correct phone number can be entered)3. Verify the passwordvarpass =/^[a-za-z]\w{5,15}$/;//Regular expression to determine the user password (beginning with a letter, length between 6~16, can contain only characters, numbers, and underscores)4. Verification CodevarCode =/^\d{4}$/;//Regular expression to determine the format of the verification code (only 4 digits can be entered)

Validation with regular expressions on the registration page (Js/aspx.cs)

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.