0

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?

4

1 回答 1

0

但是当我尝试将面具更改为{{ a{1,20} }}\{\{ a{1,20} \}\}它打破

使用双反斜杠:

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

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

或者先定义一个不同的ecsapeChar自己 - https://github.com/RobinHerbots/Inputmask#escapechar

于 2017-09-06T12:06:10.643 回答