Date Validation in Struts

Discussions

Web tier: servlets, JSP, Web frameworks: Date Validation in Struts

  1. Date Validation in Struts (1 messages)

    Hi there. I am a relative newbie to struts and I am experiencing problems validating date fields in my forms. The validation is working on String fields (length, mask etc) but the date fields are apparently escaping validation and I get sql errors as the data is rejected by a MySQL database.
    I have removed the validate() method from my Action Form, which extends ValidatorForm. My code in validation.xml is as follows:
    <field property="tour.endAt"
              depends="required,date">
              <arg0 key="tourform.endAt"/>
              <var>
                      <var-name>datePatternStrict</var-name>
                      <var-value>yyyy-MM-dd</var-value>
                     </var>
    </field>
    This is a most perplexing problem and any help would be much appreciated.
    Cheers
  2. Struts 2 Date format[ Go to top ]

    Hi, Learn how to use Struts 2 tags to format date and numbers. Read more at http://www.roseindia.net/struts/struts2/date/struts-2-date-format.shtml Thanks