Hi all,

I'm almost there with using the validator over several pages with a single form. 
However I'm getting a strange little error. The first page is validating fine, and it 
doesn't seem to try to validate the info required on the second page - correct. 
However once I try to validate the second page, the javascript validates correctly, 
but the server side validation returns an error saying the first page's required field 
needs validating. 

I think it might be because I'm not sure how to pass the page parameter to the action. 
I've tried using a html:hidden tag. Anyway, snippets from the jsps, struts config and 
validation.xml file are included below. 

If someone could help me out I'd be very grateful. Thanks very much,
Brian.




My first jsp named "validatestep1.jsp" looks like:

<html:javascript formName="validateForm" page="1"/>

<html:form action="/secure/validateStep1.jspa" onsubmit="return 
validateValidateForm(this);" method="post">
    <html:hidden name="validateForm" property="page" value="1" />
<table>
 <tr><td>username</td>
  <td><html:text name="validateForm" property="userName" /></td>
 </tr>
 <tr>
  <td colspan="2" align="center">
   <html:image border="0" page="/images/button_submit.gif"/>
  </td>
  </tr>
</table>
</html:form>

My second jsp named "validatestep2.jsp" looks like

<html:javascript formName="validateForm" page="2"/>
<html:form action="/secure/validateStep2.jspa" onsubmit="return 
validateValidateForm(this);" method="post">
    <html:hidden name="validateForm" property="page" value="2" />
<table>
 <tr>
  <td>credit card with no spaces or dashes</td>
  <td><html:text name="validateForm" property="creditCard" /></td>
 </tr>
 <tr>
  <td colspan="2" align="center">
   <html:image border="0" page="/images/button_submit.gif"/>
  </td>
  </tr>
</table>
</html:form>


in my struts config I have

    <action
      path="/secure/validateStep1"
      type="ValidateStep1Action"
      name="validateForm"
      scope="session"
      input="/validatestep1.jsp"
      unknown="false"
      validate="true"
    >
      <forward
        name="success"
        path="/validatestep2.jsp"
        redirect="false"
      />

and then

    <action
      path="/secure/validateStep2"
      type="ValidateStep2Action"
      name="validateForm"
      scope="session"
      input="/validatestep2.jsp"
      unknown="false"
      validate="true"
    >
      <forward
        name="success"
        path="/validated.jsp"
        redirect="false"
      />

In my validation.xml file I have


      <form name="validateForm">
              <field property="userName" depends="required,minlength" page="1">

              <field property="creditCard" depends="required,creditCard" page="2">

Reply via email to