You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nina Bertilsdotter <ni...@avinode.com> on 2004/03/15 11:08:52 UTC

Form Validation

Hi People,
I'm pulling my hair out trying to get form validation to work through the
validator, any help will be much appreciated.  In this example I'm trying to
validate a single field ("year" of type int), should be pretty easy, one
might think, but alas, I'm stuck and I can't get it to work. I'm sure it is
something simple but I've gone blind from looking at it. Thanks.
 
JSP:
<html:form action="MyAction.do">
<html:errors/>
<html:text property="year"/>
 
Struts-config:
 
<form-beans>
        <form-bean  name="myForm" type="myForm"/>
</form-beans>
<action   path="MyAction "
              type="packageName/MyAction"
              scope="request"
              name="myForm"
              input="myPage.jsp ">
        <forward name="success" path="myPage.jsp"/> 
</action>
 
Validation.xml:
 
<form name="MyAction"> 
          <field property="year" depends="required,integer,intRange">
                <arg0 key="MyAction.year"/>
                <arg1 name="intRange" key="${var:min}" resource="false"/>
                <var>
                    <var-name>min</var-name>
                    <var-value>1900</var-value>
                </var>
           </field>             
</form>