I have two radio buttons and validate to make sure from date is less than to date and your problem pretty much follows in the same line. In validation.xml file for the form which has from and todat I create a twofields method which is depended for to_dt.
validation.xml E.x: <form name="TNECriterisForm> <field property="from_dt" depends="required"> </field> <field property="to_dt depends="required,twofields" <arg0 key"fromdisplayname"/> <arg0 key"fromdisplayname"/> <var> <var-name>secondProperty</var-name> <var-value>from_dt</var-value> </var> </form> the twofields is custom validation to validate to_dt is greater than from_dt. In validation-rules.xml files <validator name="twofields" classname="com.check.validation.DataValidation" method="validateTwoFields" msg = "errors.twofields"/> SO from validation-rules.xml file you notice the classname and create a java file to validate these fields as follows package com.check.validation.DataValidation; import java.io.Serializable; import java.util.Locale; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionErrors; import org.apache.regexp.RESyntaxException; import org.apache.commons.validator.Field; import org.apache.commons.validator.GenericValidator; import org.apache.commons.validator.ValidatorAction; import org.apache.commons.validator.ValidatorUtil; import org.apache.struts.validator.util.StrutsValidatorUtil; import java.text.*; import java.util.*; /** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2002</p> * <p>Company: </p> * @author unascribed * @version 1.0 */ public class DataValidation implements Serializable { public DataValidation() { } public static boolean validateTwoDateFields(Object bean, ValidatorAction va, Field field, ActionErrors errors, HttpServletRequest request,ServletContext application) { String toDate = ValidatorUtil.getValueAsString(bean,field.getProperty()); String sProperty2 = field.getVarValue("secondProperty"); String fromDate = ValidatorUtil.getValueAsString(bean,sProperty2); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy"); ParsePosition pos = new ParsePosition(0); ParsePosition pos1 = new ParsePosition(0); Date fromDt = sdf.parse(fromDate,pos); Date toDt = sdf1.parse(toDate,pos1); System.out.println("fromDate in date to compare is "+fromDt); System.out.println("toDate in date to compare is "+toDt); if (fromDt.after(toDt)){ System.out.println("From Date is greater than to date"); errors.add(field.getKey(),StrutsValidatorUtil.getActionError(application,req uest,va,field)); return false; } return true; } } -----Original Message----- From: Juan Alvarado (Struts List) [mailto:[EMAIL PROTECTED]] Sent: Sunday, September 01, 2002 2:13 PM To: Struts Users Mailing List Subject: RE: Validator and depends element If you don't mind, when you get a chance can you post the details involved in this. I'm sure I along with many others will find this useful. Thanks a lot. ********************************************** Juan Alvarado Internet Developer -- Manduca Management (786)552-0504 [EMAIL PROTECTED] AOL Instant Messenger: [EMAIL PROTECTED] -----Original Message----- From: Chilukuri, Pratap N Mr CONT USAREC [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 24, 2002 1:59 PM To: 'Struts Users Mailing List' Subject: RE: Validator and depends element You got to write a custom validation method in validation-rules.xml file to handle this kind of cross validation. Let me know if you need this in detail.. -----Original Message----- From: Juan Alvarado (Struts List) [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 24, 2002 1:15 PM To: Struts Subject: Validator and depends element Does anyone know if the validator can be configured in such a way that if you have two radio buttons on a page and a text box, to only validate the contents of the text box when only a particular radio button is checked. Ex: Two radio buttons A & B and Textbox C. If B is checked then I want to validate the contents of C. Otherwise I don't want to validate anything. If anyone has an example of something like this, I would appreciate it if you'd get back with me. Thanks JDA -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>