File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Validate field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validate field" Watch "Validate field" New topic

Validate field

Tmmet Johnson
Ranch Hand

Joined: Nov 03, 2004
Posts: 56
Is there a way in Struts to validate a field , only, if it has a value?
I have a Email id field which I want to validate only if the user enters a value in that field,if not, I don't want it to validate.
Could anyone let me know how this can be done?
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

In the validation framework all validations only run when a value is entered by default (other than the "required" validation of course). You do not need to do anything special.

If you are not using the validation framework you can simply skip validation when a field's value is null or empty string.

A good workman is known by his tools.
I agree. Here's the link:
subject: Validate field
It's not a secret anymore!