Allow special chars by choice
michaelworm opened this issue · comments
Thanks for the great and easy to use plugin but I am missing some key feature. How can I accomplish to allow some special chars like +
or -
keys? I tried allowing them via regex ^[\d +-]+$
in the pattern attribute, but this doesn't seem to work. Any tips?
Please check the PR which should solve this issue :)
@michaelworm Have you tried the mask
directive in the same library?
@changhuixu it's not about filling these keys into the input as a value but for my usecase I am using these keys to trigger actions like saving or jumping to another field. Since only numbers are allowed to pass through and any other keypress is denied, I can't get this working without allowing specific keys as you can see in the commit.
I see.
Could you add an e2e test? If not, I can add one.
I won't be able to add one soon, could you do it? Thanks in advance.
Sorry, your pull request didn't work on my end. Could you try again?
Add an example input to the digit-only-demos.component.html
<section>
<h3><code>digitOnly</code> directive: allow Specific Keys</h3>
<label for="digit-only-allow-keys">
Digit Only input allows keypress of specific keys
</label>
<input
id="digit-only-allow-keys"
type="text"
name="calculate"
placeholder="00"
inputmode="numeric"
pattern="[0-9]*"
digitOnly
allowKeys="Slash,BracketRight,NumpadAdd,NumpadSubtract"
/>
</section>