Page 1 of 1

p:inputMask for ip address

Posted: 27 May 2011, 15:31
by nishern
Hi there..

Im trying to use primefaces <p:inputMask for ip address input but it does not seem to allow me to do this.
I have tried

Code: Select all

<p:inputMask value="#{bean.ip}" mask="999.999.999.999" size="20"/>

but this restricts input to minimum of 3 numeric characters between every ".".
I want it to work for all kind of IP's where example:
"xxx.xx.xxx.x"
"xxx.x.xx.xx"
"xxx.xx.xxx.xxx"

Thanks in advance...
Nish

Re: p:inputMask for ip address

Posted: 02 Jun 2011, 08:47
by nishern
Hi there,

Not sure what you meant by "mask your ip address with any other ip address"?
Im someone out there has had a similar problem:) and has found a fix...
you are right it is a tough one to crack....

Re: p:inputMask for ip address

Posted: 02 Jun 2011, 08:54
by cagatay.civici
That comment was from a spam user so I've deleted.

Currently masked input does not support this so it must be fixed number of characters, something we are trying to improve soon.

Re: p:inputMask for ip address

Posted: 02 Jun 2011, 09:00
by nishern
Hi there...
Thanks for the update... eagerly await that functionality :)

Re: p:inputMask for ip address

Posted: 02 Jun 2011, 09:02
by cagatay.civici

Re: p:inputMask for ip address

Posted: 11 May 2022, 11:57
by flawesome
Unfortunately the inputMask does not really work well for an IP address.

Instead you could use a regular input field with a keyFilter and RegEx to accomplish this.

Here an example of how this could look like:
https://stackblitz.com/edit/github-a94a ... onent.html