I'm using keyfilter from Primefaces extensions library, <pe:keyfilter/>. I use it together with regular expression which permits only numbers to be input. Everything works fine except that I can't paste a value into a field even if it fulfills regex. I mean I can't perform ctrl+v or right click -> paste with the mouse.
Is there workaround of this issue?
Or should I just use another validation method?
Primefaces extension keyfilter doesn't allow to paste values
-
- Posts: 34
- Joined: 12 Feb 2014, 17:03
I use Primefaces 5.1 with Apache MyFaces 2.0.2 and Websphere 8.0.0.9
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
Set preventPaste to false.
But, e.g. if you only allow numbers and paste a text, it won't be removed. It's just a keyfilter, no mask.
But, e.g. if you only allow numbers and paste a text, it won't be removed. It's just a keyfilter, no mask.
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
-
- Posts: 34
- Joined: 12 Feb 2014, 17:03
Thank you, I added also back-end validation to overcome this issue.
I use Primefaces 5.1 with Apache MyFaces 2.0.2 and Websphere 8.0.0.9
Is there any way to apply filter to paste also? eg. when I paste text on number only field??tandraschko wrote: ↑25 Aug 2014, 10:46Set preventPaste to false.
But, e.g. if you only allow numbers and paste a text, it won't be removed. It's just a keyfilter, no mask.
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
No. It's a keyfilter, not a mask. I would use inputMask or something.
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
Ya, but inputMask is a separate input field I need to add filter to existing one's . And does inputMask allows RegExp in mask field?tandraschko wrote: ↑13 Mar 2018, 11:20No. It's a keyfilter, not a mask. I would use inputMask or something.
I've recently faced the exact same issue.
For some reason the keyFilter in combination with a custom filter does not accept any pasting at all.
You can refer to this github issue as well:
https://github.com/primefaces/primeng/issues/4850
You can workaround by simply defining a paste-event for the input field.
If you have issues with that you can take a look at the following stackblitz example.
There are several events defined such as the paste-event.
https://stackblitz.com/edit/github-a94a ... onent.html
Btw. bare in mind that when you work with more complex regex (e.g. for validation of credit card number or ip address) you probably have to enable the "pValidateOnly" property.
Otherwise you won't be able to enter any key because on every key stroke the regex tries to validate which will most probably fail and blocks the input.
For some reason the keyFilter in combination with a custom filter does not accept any pasting at all.
You can refer to this github issue as well:
https://github.com/primefaces/primeng/issues/4850
You can workaround by simply defining a paste-event for the input field.
If you have issues with that you can take a look at the following stackblitz example.
There are several events defined such as the paste-event.
https://stackblitz.com/edit/github-a94a ... onent.html
Btw. bare in mind that when you work with more complex regex (e.g. for validation of credit card number or ip address) you probably have to enable the "pValidateOnly" property.
Otherwise you won't be able to enter any key because on every key stroke the regex tries to validate which will most probably fail and blocks the input.
This is about PrimeFaces, not PrimeNG.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub: https://github.com/jepsar
Spotify: 90s Rave, Acid, Trance, House
GitHub: https://github.com/jepsar
Spotify: 90s Rave, Acid, Trance, House
-
- Information
-
Who is online
Users browsing this forum: No registered users and 23 guests