473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

validateRegExpr in JSF

Hi, all
I want to make validation for phone number and i am using jsf's <t:validateRegExpr/> tag i required pattern with the following criteria.
user can enter only number , -(hypen) will be acceptable and () bracket also acceptable and user can enter space also.
For Example: (512) 455-4586-4566.

Thanks in Advance
Oct 10 '08 #1
1 2184
chaarmann
785 Expert 512MB
In order to be able to make the regular expression, we need a better description from you.
As what you have described so far, you can enter also:
12)8-0(-(78)8
the regular expression would be:
^[\d\)\-\s]*$

But what you need to tell us is:
- must there be at least one digit or not? for example is "" allowed or "()" or "1" or "(1)"?
- is a hyphen after a bracket allowed?
- only one opening and only one closing bracket or many? Are the brackets a must? e.g. "(123)1234-123-(0)" or "123-123-1222"?
- exactly how many hyphen? Are they a must?
- how many digits (min, max) at all? How many inside bracket? how many between which hyphen?
- are leading zeros allowed? (international calls) "0049-90123" versus "090123" versus "90123"?
- how do you note an office extension? Brackets or hyphen or space?
- What type of space can he enter? (tab, carriage-return, spacebar)

As you know,different countries have different rules for legal phone numbers. There are already a lot of regular expressions that you can google for for main countries like USA, England, Germany, India etc.. So which country do you want to implement (if any)?
Oct 10 '08 #2

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.