facebook

apply multiple validator to the same form field

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #242816 Reply

    yhqian2005
    Member

    I have a struts 1.1 app that I want to use Validator Framework to validate the user input on the browser. This app will need user to enter username and password. These two fields are both required fields and the minlength and maxlength of password is 5 and 8.

    I have myEclipse generate the validator-rules.xml, which means the validator of “required”, “minlength” and “maxlength” are generated automatically.

    And the validation.xml is like this:

    ….
    <form-validation>
    <formset>
    <form name=”logonForm”>
    <field property=”username” depends=”required”>
    <arg0 key=”LOGIN.FORM.USERNAME”/>
    </field>

    <field property=”password” depends=”required,minlength,maxlength”>
    <arg0 key=”LOGIN.FORM.PASSWORD”/>
    <arg1 name=”minlength” key=”${var:minlength}” resource=”false”/>
    <arg1 name=”maxlength” key=”${var:maxlength}” resource=”false”/>
    <var>
    <var-name>minlength</var-name>
    <var-value>5</var-value>
    </var>
    <var>
    <var-name>maxlength</var-name>
    <var-value>8</var-value>
    </var>
    </field>

    </form>
    </formset>
    </form-validation>

    When I test my app, only the “required” validator is working, and I got a popup which says
    “The user name is required. The password is required.”. The problem is I did not get any message about the minlength and maxlength validation in the popup when I input a password with length 3 and 11.

    Why only the “requred” validator work?

    I really appreciate!

    #242856 Reply

    Riyad Kalla
    Member

    yhqian2005,
    Unfortunately we don’t have any in-house expertise with the validation framework, so I don’t know that we could answer your question. Have you tried asking on the Struts mailing lists? Or checking for other folks using validation in the Sun forums (http://forums.java.sun.com)

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: apply multiple validator to the same form field

You must be logged in to post in the forum log in