Reputation: 3133
I need a PrimeFaces input component, to get/set an amount of cash, that means a Decimal with 2 digits after the floating point.
I tried using inputMask, like
<p:inputMask value="#{moneyBean.amount}" mask="999.99"/>
But I can't find some way to set a mask that accepts:
For Example, some valid inputs would be:
Any ideas to get this input in an efficient way?
Upvotes: 4
Views: 14394
Reputation: 3133
A regular expression was the best way I've found so far
<p:inputText id="numInput" value="#{val.value}" required="true"
label="#{val.title}" validatorMessage="Not valid Number">
<p:ajax event="change" process="@form" update=":edit_main" />
<f:validateRegex pattern="^[-+]?[0-9]*\.?[0-9]{1,2}+$" />
</p:inputText>
<p:message for="numInput" />
Upvotes: 3
Reputation: 422
you can use Client Side Validation tag visit link
http://www.primefaces.org/showcase/ui/csvEvent.jsf
There are so may example that can help you. i think your problem will be resolved by these two tag
<f:validateDoubleRange minimum="5.5" maximum="8.5" />
and
<p:clientValidator />
tell if not work.
Now i got exactly what you want. you want only two digit after "."
The Prime Faces extensions
are provide such type of checks.
Go throw the link
http://www.primefaces.org/showcase-ext/sections/inputNumber/advanceUsage.jsf
it will sure help you.
Upvotes: 0