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)