my dog learned polymorphism*
The moose likes Struts and the fly likes need a validator to check the number is positive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "need a validator to check the number is positive" Watch "need a validator to check the number is positive" New topic
Author

need a validator to check the number is positive

Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

hi,

This is a very basic question I guess, but I am a newbie with Struts
Before submitting my form, I would like to validate it.

In validator-rules.xml, there is the validator "required" to check that a field has been filled.
Does anyone know of a validator that checks if the number entered is positive ?


Thanks


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCBCD 5
Visit my blog
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
since you're a newbie, i hope you are going with a later struts version, that is 1.2+ . with 1.2.x your can use the validwhen rule. simply test for *this* > 0 (see the struts user guide on validation for this). you can use also 'range' validation, but i believe you need to specify the max with this rule.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
 
Don't get me started about those stupid light bulbs.
 
subject: need a validator to check the number is positive