Search code examples
kendo-ui-angular2kendo-maskedtextbox

How to escape mask rules in kendo maskedtextbox for angular2?


I need to build a mask where some charachters are fixed, like a number where the user have to specify last three digits.

How can I escape the "0" default mask behaviour?

the docs says to use backslash character, but I can't figure out how it should works.

example: my mask needs to show the number 12000___ and user have to enter last 3 digits

html:

<kendo-maskedtextbox [mask]="mask"></kendo-maskedtextbox>

ts:

mask = "12\0\0\0000";

but it doesn't compile...


Solution

  • A backslash is a escape character in (JavaScript) strings, thus you need to escape the backslash.

    Like this: mask = "12\\0\\0\\0000"

    I've also prepared a Plunkr.