2

I want to add a inputmask which is supposed accept phone numbers in standard format. I want to give "input mask" for standard phone number format e.g: +92 321 9388233. So how to give +92 as a constant in mask? The digit 9 is not behaving as constant. how to make digit 9 constant.

MSR
  • 535
  • 7
  • 19
Rabia Naz khan
  • 507
  • 4
  • 13
  • Maybe you can try it with a simple `` and validate it with a given regex on server side? – alexander Mar 13 '15 at 20:22
  • Possible duplicate of [Escape Number 9 in p:inputmask](https://stackoverflow.com/questions/39913451/escape-number-9-in-pinputmask) – borchvm Sep 25 '19 at 09:10

2 Answers2

0

Digit 9 is defined as a mask for all digits. If you want it as a constant, you can try writing your own regular expression like this:

<p:inputMask>
    <pe:keyFilter regEx="\\+92[0-9 ]+" />
</p:inputMask>

Update

I found better solution, since this one doesn't work.

You can redefine mask definitions in JavaScript. Just add this script to your file:

$.mask.definitions['9'] = '';
$.mask.definitions['d'] = '[0-9]';

And now your mask for digits will be letter d and not number 9. So, this can be your mask:

<p:inputMask mask="+92 ddd ddddddd" />
Crepi
  • 645
  • 5
  • 15
0
<input type="text" data-inputmask='"mask": "+\\92999-9999999"' data-mask />

Just add \\ before 9 and this resolves your issue and will add a constant value like +92 at the start of a text.

Pang
  • 9,564
  • 146
  • 81
  • 122