Question

I want to restrict my <p:inputMask> with only letters and numbers without giving any size (max-legth) limit. I tried to use mask attribute but when I use mask attriibute it gives a max-length for my inputMask. Could you please help me to solve this issue ?

Sample Code :

<p:inputMask value="#{gercekKrediBasvuruDetayGirisView.kisi.ticariHarfSeri}"
  required="true" mask="***" 
  requiredMessage="#{msg['GercekKrediBasvuruTuketiciMaliBilgiler.belgeSeriNull']}"
/>
Was it helpful?

Solution

If your input does not have to be <p:inputMask> and can be <h:inputText> or <p:inputText> then the easiest way to go would be to use it with regex:

<h:inputText id="inputField" value="#{backingbean.username}" validatorMessage="Value does not match pattern.">
        <f:validateRegex pattern="^[a-zA-Z0-9]+$" />
</h:inputText>
<h:message for="inputField" />

If you only allow lower case letters go with ^[a-z0-9]+$. <p:inputMask> is designed for somewhat stricter validation than only letters and numbers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top