How to specify a jquery inputmask that is either a number or a fixed string?

503 Views Asked by At

The goal is for the user to input a 9 digit number or a string with the value "YOUR NAME". Something like:

 <input type="text"
        data-inputmask="'mask': '(999999999)|(YOUR NAME)'">

I know that doesn't work, but I've tried a lot of different variations and none work.

Is there a way to do this with jquery inputmask?

1

There are 1 best solutions below

0
On

The secret is you need to escape constant values. As in:

data-inputmask="'mask': '(999999999)|(\\Y\\O\\U\\R\\ \\N\\A\\M\\E)','rightAlign':false"