• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need a validator to check the number is positive

 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic