--- Chamara Gunaratne <[EMAIL PROTECTED]> wrote:
> I am using struts2 to validate form input. For some reason I can't figure
> out, the short-circuit="true" attribute is not working. Everything else
> seems to be working fine. The validation rules are embedded in  a
> action_class_name-validation.xml file. Here's a sample from the xml file:
> 
>    <validators>
>    <field name="user.firstName">
>          <field-validator type="required" short-circuit="true" >
>             <message>Please enter your first name.</message>
>          </field-validator>
> 
>          <field-validator type="regex"  short-circuit="true" >
>             <param name="expression">^[a-z.\-, A-Z]+$</param>
>             <message>First Name may only contain letters, spaces, dashes,
> or
> periods</message>
>          </field-validator>
>    </field>
> 
>    <field name="user.lastName">
>          <field-validator type="required" short-circuit="true" >
>             <message>Please enter your last name.</message>
>          </field-validator>
>          <field-validator type="regex"  short-circuit="true" >
>             <param name="expression">^[a-z.\-, A-Z]+$</param>
>             <message>Last Name may only contain letters, spaces, dashes, or
> periods</message>
>          </field-validator>
>    </field>
> 
>    </validators>
> 
> If the form is submitted with a blank user.firstName field, I would get
> both
> error messages. From what I understand of how the validations work, only
> the
> first test would fire if short-circuit is enabled. 

I'm surprised the first "required" validator is firing at all; normally you'd
use "requiredstring" for a text field; a "required" validator will never
(more or less) fire for a text field in an HTML form.

Is the lastName validation working properly? If so then perhaps you've
spelled the name of your field wrong on the form.

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to