numeric validation in struts2
i want to validate textfield which sh开发者_运维问答ould allow only number 0-9 in any range how can i implement this
Struts2 ships with pretty good documentation. Learn how to use it :)
- Start here.
- There's chapter Validation.
- Check section Bundled Validators.
- You want to use int validation.
I'm not sure what you mean by "in any range". To do numeric validation you can use the int validator:
<validator type="int">
<param name="fieldName">myfield</param>
<param name="min">0</param>
<param name="max">9</param>
<message>MyField needs to be between ${min} and ${max}</message>
</validator>
I assume you just want integers and not real numbers.
This page describes all the validators that are available.
精彩评论