File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Alphabets  only valitation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Alphabets  only valitation" Watch "Alphabets  only valitation" New topic
Author

Alphabets only valitation

prem ranjith
Greenhorn

Joined: Jul 03, 2009
Posts: 13
Hellow friends

How to validate the text field, alphabets only.. any one can help me.

With Regards
premranjith
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Validate against a regular expression.
prem ranjith
Greenhorn

Joined: Jul 03, 2009
Posts: 13
have any example.. becase i am new one

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I don't know what version of Struts you're using.
prem ranjith
Greenhorn

Joined: Jul 03, 2009
Posts: 13
strts1.2
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

http://struts.apache.org/1.2.9/userGuide/dev_validator.html

See the "mask" validator.
Richard Golebiowski
Ranch Hand

Joined: May 05, 2010
Posts: 213

Design wise, wouldn't it be better to filter the user input so that only alphabetical characters are allowed?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No, although that can be done as well. Client-side validation is not a replacement for server-side validation--it is a usability enhancement.
Richard Golebiowski
Ranch Hand

Joined: May 05, 2010
Posts: 213

Not validation, filtering. Let's take the case of a phone number into a text field. Wouldn't the best practice be to only allow numbers to be input into that field? What's the point of doing it server side and kicking it out when the user could have been saved the hassle on the client side of having to redo it? Server side validation is still good to do to as a precaution, but as good design shouldn't the first step be to prevent invalid input?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Richard Golebiowski wrote:Not validation, filtering. Let's take the case of a phone number into a text field. Wouldn't the best practice be to only allow numbers to be input into that field? What's the point of doing it server side and kicking it out when the user could have been saved the hassle on the client side of having to redo it? Server side validation is still good to do to as a precaution, but as good design shouldn't the first step be to prevent invalid input?

As I said, client-side [whatever you want to call it] is fine, but ultimately is nothing but user experience enhancement. Input filtering a subset of validation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Alphabets only valitation
 
Similar Threads
regex problem
Regular Expression in ruby
text field
JTextField
Editable JComboBox that must accept only alphabets