• 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.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!