1

I have a PrimeFaces InputText. I Need to make it accept only numbers, that are greater than zero.

I have tried this approach.

<p:inputText id="levelId"
    value="#{myBean.levelValue}" converter="spaceConverter">
    <pe:keyFilter  for="levelId" regEx="/^[1-9][0-9]*$/i" />
</p:inputText>

But this won't allow the input of 0 at all. That is, by the above approach I cant enter 10.


I tried the following approach as well:

<pe:inputNumber decimalPlaces="0" id="levelId"
        value="#{myBean.levelValue}"minValue=1 maxValue="10">                   
</pe:inputNumber>

PS: default value of levelValue is 1

In this approach it won't allow me to remove the default value and enter other value(ex:4) because minValue is set to 1


How do I solve this?

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Harihara_K
  • 174
  • 16

0 Answers0