byCoder
byCoder

Reputation: 9184

How to do that pattern for input html5?

I need to generate such pattern for my input, for example:

+375 29 911-91-91

in general, it looks like this:

+375 XX XXX-XX-XX

Note the spaces!

I tried this:

[\+][\ ]\d{3}[\ ]\d{2}\d{3}[\-]\d{2}[\-]\d{2}

Will this work in IE?

Upvotes: 0

Views: 193

Answers (2)

Dima
Dima

Reputation: 1065

+\s*\d{3}\s+\d{2}\s+\d{3}-\d{2}-\d{2}

Upvotes: 0

TheZ
TheZ

Reputation: 3732

\+\d{3}\s\d{2}\s\d{3}\-\d{2}\-\d{2}

Should work. You also don't need to put the square brackets [ and ] around every character unless you want to do an or [a|b] test or you need to do a range of characters [a-z].

Upvotes: 1

Related Questions