ExtJS Phone Number Validation
January 6, 2010
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
Cheers
Ext Grid to Grid DNG Extjs 5 steps to understand DND
![[del.icio.us]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/digg.png)
![[dzone]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/dzone.png)
![[Facebook]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/facebook.png)
![[Friendsite]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/friendsite.png)
![[Google]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/google.png)
![[LinkedIn]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/linkedin.png)
![[MySpace]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/myspace.png)
![[Twitter]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/twitter.png)
![[Windows Live]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/windowslive.png)
![[Yahoo!]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/yahoo.png)
![[Email]](http://mavendeveloper.com/wp-content/plugins/bookmarkify/email.png)