Force users to enter only digits in JSF

Hi,

if you want to force user to enter only digits while entering a numeric data like age, amount etc. you can use PrimeFaces’ inputMask component as follows:

<p:inputMask id="age" label="Age" value="#{bean.age} placeHolder=" " mask="?99"/>

This component with ?99 mask forces users to enter ages from 0 to 99

Easy, huh?

You can see other possible masked inputs from here : http://primefaces.org:8080/prime-showcase/ui/inputMask.jsf

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s