jquery inputmask: masking curly braces

667 views Asked by At

I want to wrap my user input with double curly braces, i.e. sometext -> {{ sometext }}. I have succeeded with wrapping the input using Inputmask, but cannot make it understant curly braces literally.

here is an example with wrapping the input with %% double percentages %%:

$('#masked').inputmask({
  mask: "%% a{1,20} %%"  
});

https://jsfiddle.net/vm2uu4xd/

But when I try to change the mask to {{ a{1,20} }} or \{\{ a{1,20} \}\} it breaks:

TypeError: Cannot read property 'isGroup' of undefined

What is the proper format for this?

1

There are 1 answers

0
CBroe On BEST ANSWER

But when I try to change the mask to {{ a{1,20} }} or \{\{ a{1,20} \}\} it breaks

Use double backslashes:

mask: "\\{\\{ a{1,20} \\}\\}"

https://jsfiddle.net/vm2uu4xd/2/

Or define a different ecsapeChar yourself first - https://github.com/RobinHerbots/Inputmask#escapechar