You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Carl Walker <wa...@georgetown.edu> on 2003/11/25 15:15:44 UTC

Validator and Float Validation

Hello,

I'm having a problem using the Validator and the 'float' validation.  My
problem is that the Validator doesn't seem to work if I enter text
(letters) into the html:text box.  I am using the <html:errors> tag for
error messages.

In my struts-config.xml file, I have the following definition of a
DynaValidatorForm.

<form-property name="actTotalHours" type="java.lang.Float"
initial="0.0f" />

In my validation.xml file, I have the corresponding element.

      <field property="actTotalHours" depends="float,floatRange">
        <arg0 key="label.actTotalHours" />
 <arg1 name="floatRange" key="0" resource="false" />
 <arg2 name="floatRange" key="5,000" resource="false" />
 <var>
   <var-name>min</var-name>
   <var-value>0.0f</var-value>
 </var>
 <var>
   <var-name>max</var-name>
   <var-value>5000.0f</var-value>
        </var>
     </field>

Please note that the floatRange function works.  If I enter a number
like '100000', I will get the appropriate error displayed by the
html:errors tag.

However, if I enter 'blah' or some other text string in the html:text
box, the form submission will associate '0.0f' (the initial value) with
the submission.

What I'd like to happen is to have an error generated if I attempt to
stuff a non-float into the html:text box.

Is this the way it's supposed to work, or am I missing something.

Thanks,
Carl Walker


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org