ExtJS Phone Number Validation

Validate Phone Number With regex

Extjs has give us vtype for phone number validation but with this all the requirements are not full-filled …. we may need different type of phone number validation then the default vtype provided by Extjs What ?????? to do in this case…. !!!
Well don’t panic, we have other options to do this too … we can use regex to meet our desire validation….

Let’s Get Started then
1) don’t use numberfield rather you textfield
2) use regex for phone validation

Syntax :
regex: /^[(+{1})|(00{1})|(1425{1})|(1445{1})]+([0-9]){7,10}$/,

if you use this regex it only validated the phone no if :
-> it starts with + OR
-> it starts with 00 OR
-> it starts with 1425 OR
-> it starts with 1445

if you only want to validate with + and 00 then just remove |(1425{1})|(1445{1})
Now your regex will look like this:
Syntax :
regex: /^[(+{1})|(00{1})]+([0-9]){7,10}$/,

regex is very useful … Happy Coding ExtJS


Leave a Reply