You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Richmond Te <ri...@yahoo.com> on 2002/12/05 00:51:13 UTC

validating float fields

i have a 2dimensional array of fields that accept items and amount. i have amended the validateFloat method and validateMask method to keep iterating 

if errors are found so that error messages would appear for the whole list and not one by one, per row. (by commenting out the return false)

the problem is that if x is entered in amount, all three error messages appear for the "depends" attribute. 

if 0.0001 is entered, two of the three error messages appear, etc.

my query is - how do i validate all fields in a list ( ten of them ) and make it stop 

once the first rule is not met, ie. row 1 col 1 is not numeric, row 2 col 2 is also not numeric. therefore just validate via "float" attribute for the two fields and continue with 

the "mask" and "range" and just display "not numeric" instead of all three messages relative to the depends rule.

i have the following rule in my validation.xml:

<field property="item" depends="mask" indexedListProperty="list">

<msg name="mask" key="errors.invalid"/>

<arg0 key="Form.item.displayname"/>

<var>

<var-name>mask</var-name>

<var-value>^[\w\d]*$</var-value>

</var>

</field>

<field property="amount" depends="float,mask,range" indexedListProperty="list">

<msg name="float" key="errors.numeric"/> 

<msg name="mask" key="errors.amount.format"/>

<msg name="range" key="errors.range"/>

<arg0 key="form.amount.displayname"/>

<arg1 name="range" key="${var:min}" resource="false" /> 

<arg2 name="range" key="${var:max}" resource="false" /> 

<var>

<var-name>mask</var-name>

<var-value>${amountSet}</var-value>

</var>

<var>

<var-name>min</var-name> 

<var-value>0.01</var-value> 

</var>

<var>

<var-name>max</var-name> 

<var-value>9999.99</var-value> 

</var>

thanks for any suggestions..



---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now