hello guys..Im new in struts programming.. Just need your help on this matter..
I already made validations using validation.xml and validation-rules.xml for html:text.. Now, how will I validate my form for checkbox and multibox? Can I include it in my validation.xml or separate process?
With a single checkbox, there's really nothing to validate: It's either checked or it isn't, and the fact that it's on the page at all usually means that both checked and unchecked are valid states for the checkbox. About the only case I can think of where you might want to validate a single checkbox would be where you expect someone to check the box to indicate that they "agree to the terms and conditions... blah blah blah.." just to satisfy some legal requirement. In this case, just apply the "required" rule, and it will only be valid if it's checked.
In the case of a multibox, or a series of checkboxes that share the same property name, you may want to validate that at least one of the boxes has been checked. In that case, simply apply the "required" rule for that property, and Struts will return an error if at least one of the boxes is not checked. [ July 26, 2007: Message edited by: Merrill Higginson ]
it working now! thanks for your help.. However, I have a new problem regarding order of checking.. here how it goes.. 1. choose between the two radio buttons 2. if radio1 is choose, it will check 5 checkboxes(defined as multibox) 3. if checkbox1 is choose, it will check if text areas are filled-up..
Can I make some flags in validation.xml? I mean if radio1 is true, it will check the multibox..and if checkbox1 of that multibox is true, then it will check the textarea..
Thank you very mych again... Arigatou!
posted 13 years ago
There is a "validwhen" rule that allows you to validate one field based on the value of another. I will tell you in advance that it doesn't cover every possibility. If you have a fairly complex scenario, I'd recommend that you just write a custom validation rule.
To find out more about how to use validwhen see the section entitled Designing Complex Validations with validwhen in this link