-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
PrimeFaces Beginner's Guide
By :
The InputMask component can be used to read input in a specific format. For example, we may want the user to enter a phone number in the XXX-XXX-XXXX format. We can use the <p:inputMask> component to read the input in the given format, restricting the user from entering invalid data:
<p:inputMask value="#{userController.registerUser.phone}" mask="999-999-9999"/>The mask template can have the following characters, which have special meaning:
9: Represents a single digit, that is from 0 to 9.
a: Represents an alphabetic character, that is from A to Z and a to z.
*: Represents any alphanumeric character, that is 0 to 9, A to Z, or a to z.
Let us see a few examples of mask templates:
<p:inputMask mask="(999) 999-99-9999"/>
This mask template (999) 999-99-9999 restricts the input to contain any digit in place of 9 in the template. It won't allow the user to enter any non-digit character in place of 9.
Some valid inputs are: (111...
Change the font size
Change margin width
Change background colour