Search code examples
jquerykendo-uikendo-maskedtextbox

Kendo MaskedTextBox data attributes


Can MaskedTextBox be configured via data attributes?

I tried the following but did not work.

<input data-role='kendo.ui.MaskedTextBox' data-mask='(999) 000-0000' />

Thanks.


Solution

  • It can; are you sure you're instructing Kendo UI to initialize the DOM elements (either by calling kendo.init or by binding a view model)? Both of these work:

    <div id="example">
        <input data-role="maskedtextbox" data-mask="(999) 000-0000" />
        <input data-role="kendo.ui.MaskedTextBox" data-mask="(999) 000-0000" />
    </div>
    
    $(function() {
        kendo.init($("#example"));
    });
    

    (demo)