Hi All, 
I have the following setup for validating certain fields. I have written a custom 
validator for validating certain date logic.
 
validation-rules.xml
 
<validator name="xxxDates"
  classname="com.xxxValidator"
  method="validatexxxDates"
  methodParams="java.lang.Object,
    org.apache.commons.validator.ValidatorAction,
    org.apache.commons.validator.Field,
    org.apache.struts.action.ActionErrors,
    javax.servlet.http.HttpServletRequest"
  msg="errors.date.lessthanequal">
</validator>
 
validator.xml
 
<field property="presentationStart"  depends="required,date,xxxDates">
             <arg0 key="presentationStart"/>
             <var>
              <var-name>datePatternStrict</var-name>
              <var-value>MM/dd/yyyy</var-value>
              <var-name>secondProperty</var-name>
              <var-value>presentationEnd</var-value>
             </var>
         </field> 
  <field property="presentationEnd"  depends="required,date,xxxDates">
             <arg0 key="presentationEnd"/>
             <var>
              <var-name>datePatternStrict</var-name>
              <var-value>MM/dd/yyyy</var-value>
              <var-name>secondProperty</var-name>
              <var-value>presentationStart</var-value>
             </var>
         </field>
 
and on my jsp
<html:form  action="/propertyOffer" onsubmit="return validatePropertyFormBean(this);">
<html:text property="presentationStart" size="20"  />
<html:text property="presentationEnd" size="20"  />

<html:javascript formName="propertyFormBean"/>
 
Ok this works like a charm, if i submit the form without any values i get a javascript 
popup alert saying presentationStart is required, presentationEnd is required. 
However, when i put a value in presentationStart and submit i dont get a js popup for 
presentationEnd, however the validation runs and i get a server side error saying 
presentationEnd is required. So my question is when you put in a custom validator for 
one of the fields why doesnt it evaluate the required validation (javascript) for the 
2nd field? is this a bug? Any help would be appreciated. If i remove my custom 
validator(xxxDates) from both fields, the js required pop up runs smoothly for the 2nd 
field if the first one is not null. So to recap when you put in a custom validator for 
one of the fields the validator doesn't run through the rest of the fields until it 
has performed the serverside validation on the custom validator for the 1st field. I 
am using struts 1.1 with validator as plug-in
 
Ameer
 


---------------------------------
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.

Reply via email to