In js, the regular expression is used to search for letters and numbers.
Let's not talk about it. Let's take a look at how to use regular expressions to search for letters and numbers in Javascript. The specific code is as follows:
<! Doctype html>
The following describes how to use a regular expression to verify that the password contains numbers and letters.
The script must contain at least one digit and one letter as follows:
Function CheckPassWord (password) {// The password must contain numbers and letters var str = password; if (str = null | str. length <8) {return false;} var reg = new RegExp (/^ (?! [^ A-zA-Z] + $ )(?! \ D + $)/); if (reg. test (str) return true ;}
It must contain numbers and letters, and cannot contain special symbols. The script method is as follows:
Function CheckPassWord (password) {// it must be a letter with a number and a length of no less than 8 characters var str = password; if (str = null | str. length <8) {return false;} var reg1 = new RegExp (/^ [0-9A-Za-z] + $/); if (! Reg1.test (str) {return false;} var reg = new RegExp (/[A-Za-z]. * [0-9] | [0-9]. * [A-Za-z]/); if (reg. test (str) {return true;} else {return false ;}}
Now, it's over. I hope it will help you!