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 only if field is visible? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validate only if field is visible?" Watch "validate only if field is visible?" New topic

validate only if field is visible?

shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
I have a radio button Yes/No. If user clicks 'No' I make the hidden text box visible. this textbox validation should trigger if it is empty. How to do this? if user pressed YES then the validation should not fire.

can this be done using struts validation.xml or I should stick to client side javascript?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You should be able to do this with a "validWhen" validation. See the heading "Conditionally Required Fields" in this link for more information.

Consultant, Sima Solutions
I agree. Here's the link:
subject: validate only if field is visible?
It's not a secret anymore!