Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow special chars by choice #58

Open
michaelworm opened this issue Sep 21, 2021 · 6 comments · Fixed by #59
Open

Allow special chars by choice #58

michaelworm opened this issue Sep 21, 2021 · 6 comments · Fixed by #59

Comments

@michaelworm
Copy link
Contributor

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?

michaelworm pushed a commit to essquare/ngx-digit-only that referenced this issue Sep 21, 2021
@michaelworm
Copy link
Contributor Author

Please check the PR which should solve this issue :)

michaelworm pushed a commit to essquare/ngx-digit-only that referenced this issue Sep 21, 2021
@changhuixu
Copy link
Owner

@michaelworm Have you tried the mask directive in the same library?

@michaelworm
Copy link
Contributor Author

@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.

@changhuixu
Copy link
Owner

I see.
Could you add an e2e test? If not, I can add one.

@michaelworm
Copy link
Contributor Author

I won't be able to add one soon, could you do it? Thanks in advance.

changhuixu added a commit that referenced this issue Oct 7, 2021
#58 Allow special chars by choice
@changhuixu
Copy link
Owner

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>

@changhuixu changhuixu reopened this Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants