Jim Reynolds wrote:
Using Validator in struts 1.2 Problem: I have a form that has two rows of data: The first column is a "radio" button and its value is either "new" or "old" See mimic form below So the user must select either the new or existing but not both. No big deal. Problem is for each row, there are two columns that are required: Here is a kind of visual () OLD text1[ put your data here ] text2[ put data here] or () NEW text1[ put your data here ] text2[ put data here] Here is how the form kind of lays out. <form> <input type="radio" name="URL" value="new"> <input type="text" value="newText1"> <input type="text" value="newText2"> or <input type="radio" name="UR"" value="old"> <input type="text" value="oldText1"> <input type="text" value="oldText2"> The user will select only one radio, but I must make sure that its row members are valid. So in the validator I need to find out whether new or existing was clicked, and based upon that, I need to ensure that the two members belonging to that row are valid. Not empty. Make sense?
Can you just have the two radio buttons and two text fields (rather than four text fields)? That would simplify the interface for your users and reduce the complexity of the validation a little, since you can just mark everything as 'required'.
If that's not an option, you need to do conditional validation to say that 'newText1' and 'newText2' are required if 'new' is set; 'oldText1' and 'oldText2' are required if 'old' is set (assuming I've understood you correctly).
There are a couple of validation rules you can look at for this; the first, and older option, is the 'validif' rule. The more modern option is the 'validwhen' option. Unfortunately, I can't see where the validator documentation has moved to on the new Struts site or I'd give you links... Anyone know where this is now?
L. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]