wood burning stoves*
The moose likes Beginning Java and the fly likes validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "validation" Watch "validation" New topic
Author

validation

dale con
Ranch Hand

Joined: Apr 15, 2005
Posts: 93
Hi all

I need to make sure a parameter going through to my method doesn not contains letters.

It's a phone number field so it can contain things like '-' or '+' or '()'etc but it can't contains letters

Can anyone help me write a regex for this

Many thanks
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4445
    
    5

What have you tried so far?

- Junilu
How to Ask Questions the Smart Way
Megs Maquito
Ranch Hand

Joined: May 18, 2005
Posts: 84
Not sure if this is correct but here goes:


This way if anyone would use a String as parameter i.e. phoneNumber x = new phoneNumber (abc) would result in error as the method requires an integer and not a String.


I'm a Hood Ornament
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: validation
 
Similar Threads
Morse code conversion
WA #1.....word association
Check if a String has alphabets
Problem with JSP app when calling Yahoo Geocoding API.
text file ?? simple program