This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes double validation not catching text Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "double validation not catching text" Watch "double validation not catching text" New topic
Author

double validation not catching text

K Dombroski
Ranch Hand

Joined: Dec 03, 2005
Posts: 39
I'm trying to use the struts validator (using struts 1.2.7) to make sure the user enters a double value in a given range. When I enter a number outside the given range, I get the error as expected. But when I enter text, such as "hgl," I don't get any errors. "hgl" cannot be converted to a Double, so why is the validator not catching it? I am at a loss. If anyone can help, I'd be grateful.

Here is my validation:
<field property="financialFile.useTaxRate"
depends="double,doubleRange">
<arg0 key="Financial File: Use Tax Rate"
resource="false" />
<arg1 name="doubleRange" key="${var:min}" resource="false"/>
<arg2 name="doubleRange" key="${var:max}" resource="false"/>
<var>
<var-name>min</var-name>
<var-value>000.00</var-value>
</var>
<var>
<var-name>max</var-name>
<var-value>999.99</var-value>
</var>
</field>
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
What does your form look like? If you do not have your properties there defined as Strings then the validation framework cannot detect invalid entries.

- Brent
K Dombroski
Ranch Hand

Joined: Dec 03, 2005
Posts: 39
I have useTaxRate defined as a double in my form. Will that not work?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: double validation not catching text
 
Similar Threads
Javascript error in range validation
problem in struts validation for salary range
Struts 1.x, 2, jstl questions
intRange validations
Struts: validations using 'validwhen' in validation.xml