简体   繁体   中英

mobile number validation using javascript

I am looking for a javascript code for mobile number validation in which the number should start form 789. I got the code which looks like this ^[789]\\d{9}$ . However, I dont know if this code is right and what these symbols before the numbers stand for? Can anyone explain me what these symbols stand for?

W3Schools offers a really good page about it : http://www.w3schools.com/jsref/jsref_obj_regexp.asp

^ means the begigning of the regex
[789] means that the string starts by "7" or "8" or "9".
\\d means "any digit".
{9} means 9 times.
$ means the end of string.

Conclusion : You must have a 9 chars long string, which starts with 7,8 or 9 followed by 9 numbers. So basically, the string might be "7123456789".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM