I'm using PrimeFaces for a college project. How do I make "Spinner" not accept "Characters" only numbers?
Idade:
<p:spinner id="spinnerBasic" max="120" value="#{spinnerController.number1}"/>
I'm using PrimeFaces for a college project. How do I make "Spinner" not accept "Characters" only numbers?
Idade:
<p:spinner id="spinnerBasic" max="120" value="#{spinnerController.number1}"/>
Good afternoon, you can solve this problem using javascript as below:
<script type="text/javascript">
function onlyNumbers(data){
data.value = data.value.replace(/[^0-9]/g,'');
};
</script>
And in spinner use ( you can change the time of the call if you want, using another type of event ):
<p:spinner id="spinnerBasic" max="120" value="#{spinnerController.number1}" onkeyup="onlyNumbers(this)" />