RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.39k stars 2.17k forks source link

How to restrict digits to a certain number? #2157

Open ToddHoff opened 5 years ago

ToddHoff commented 5 years ago

The goal is to be able to enter over under numbers like -1.0 or +11.5. The last digit can be either a 0 or 5. There can be a leading + or -.

A mask like:

"spread": mask: "9{1,2}.0|5", allowMinus: true, allowPlus: true

Doesn't let a negative or a positive symbol being entered. And I tried to use the numeric alias but apparently you can't add a mask. Any attempt I made at including a - or + symbol in the mask didn't work.

Any ideas?

thanks

RobinHerbots commented 5 years ago

@ToddHoff ,

Use a mask like Inputmask({regex: "[-+]?[0-9]{1,2}\.[05]", placeholder: "0"}).mask("test2");

I tested it with the latest 5.x version.

knoxcard commented 5 years ago

Can this also be applied to datetime?

$('#cardExpiration').inputmask({
    alias: 'datetime',
    inputFormat: 'mm/yy',
})

That all works great, but I want limit year (yy) from 19 to 29.