my dog learned polymorphism*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validate only if field is visible?" Watch "validate only if field is visible?" New topic
Author

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.


Merrill
Consultant, Sima Solutions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: validate only if field is visible?
 
Similar Threads
Dreamcar assignment for Part II
Problem with Struts2 validation
Disable Url
validating user input for number of seats
User Id validation problem on JSP page