Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

validate only if field is visible?

 
shah rah
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to do this with a "validWhen" validation. See the heading "Conditionally Required Fields" in this link for more information.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic