I am working in jsf and primefaces 5 and creating some mobile screen.
I want to allow only numbers in my p:inputText for mobile screen.
The below code is working fine in normal screens(i.e web application) but not working for mobile screens.
<pm:field>
<p:outputLabel value="Age" />
<p:inputText id="age" value="#{patreg.age}">
<pe:keyFilter mask="num"></pe:keyFilter>
<f:ajax event="change" listener="#{patreg.generate_DOB_FromAge}" render="dob_field"/>
</p:inputText>
</pm:field>
Is there any other way to validate/ don't allow in my p:inputText ??
Try this :
<pm:field>
<p:outputLabel value="Age" />
<p:inputText id="age" value="#{patreg.age}" onkeyup="$(this).val($(this).val().replace(/[^0-9]/g, ''));" >
<f:ajax event="change" listener="#{patreg.generate_DOB_FromAge}" render="dob_field"/>
</p:inputText>
</pm:field>