var reg=/regular expression/;
boolean reg.test(string to be verified);
js engine will convert /regular expression/"" into a RegExp object, when the string If the requirements of the regular expression are met, true will be returned.
An expression verification example I wrote: The function is as follows:
User name, cannot be empty
Password 6 is a number
Password confirmation, the password entered twice must be the same
ID card number must It is 15 digits, or 18 digits, and the end can also be Please pay attention to PHP Chinese website!