Javascript, php Regular Expression verification for mixed numbers and letters (6-15 digits)

Source: Internet
Author: User

During Website user registration, it is often necessary to verify the number of digits and letters that some fields contain, because they are not familiar with regular expressions, I 'd like to record this kind of things for use when necessary.

Php verification fields must be 6-15 characters in combination with letters and numbers

If (! Preg_match ("/^ [a-z \ d] {6, 15} $/I", $ variable )) {echo 'the password must be a combination of 6-15 digits and letters ';}

The js verification field must be a combination of 6-12 letters and numbers.

Var reg =/^ [A-Za-z0-9] + $/; if (! Reg. test (variable) | variable. length <6 | variable. length> 15) {alert ('password must be a combination of 6-15 digits and letters ');}
Articles you may be interested in
  • PHP generates continuous numbers (letters) Array Function range () analysis, PHP lottery program function
  • Php function for getting the first letter of Chinese characters and Pinyin (actually usable)
  • Php extracts the birthday date from the ID card number and verifies whether it is a minor.
  • PHP number formatting, three digits are added with commas
  • PHP functions for converting Arabic numerals into Chinese Characters
  • In php, we use the curl post method to submit data and the get method to obtain webpage data.
  • Differences between variables and functions in php after the static keyword is added
  • Javascript restricts that only numbers (including decimal places) can be entered in the text box)

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.