简体   繁体   中英

jQuery form validation regex, start with and symbol count

I'm validating phone number, it's must be "+3706 XXXXXXX" , start with "+3706" + 8 digits

My regex is /^(+3706)(8{d})/ , but it not walidating, what is wrong

Your regex should be:

/^(\+3706) *(\d{8})$/

+ needs to be escaped in regex and to match 8 digits you need to use \\d{8}

Working Demo: http://regex101.com/r/gU2cF4

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