MaskedTextBox

Description

The MaskedTextBox widget can restrict the type of input allowed by a user.

Official Kendo UI MaskedTextBox documentation

Examples

  • Basic Example
  • Passing additional options
  • Using global options

This example demonstrates passing a single option to bind against the value of the MaskedTextBox widget.

<input data-bind="kendoMaskedTextBox: value" />
<hr/>
<div data-bind="text: value"> </div>
var ViewModel = function() {
    this.value = ko.observable("test");
};

                            ko.applyBindings(new ViewModel());

This example demonstrates passing additional options in the data-bind attribute with value now being explicitly specified.

<input data-bind="kendoMaskedTextBox: { value: value, mask: '0,000.00 $' }" />
<hr/>
<div data-bind="text: value"> </div>
var ViewModel = function() {
    this.value = ko.observable(1355.75);
};

                            ko.applyBindings(new ViewModel());

This example demonstrates setting global options in ko.bindingHandlers.kendoMaskedTextBox.options. This helps to simplify the markup for settings that can be used as a default for all instances of this widget.

<input data-bind="kendoMaskedTextBox: value" />
<hr/>
<div data-bind="text: value"> </div>
var ViewModel = function() {
    this.value = ko.observable(1210.99);
};

ko.bindingHandlers.kendoMaskedTextBox.options = {
    mask: '0,000.00 $'
};

                            ko.applyBindings(new ViewModel());

Live Options

The kendoMaskedTextBox.md binding accepts all of the options that can be specified for the widget. However, when bound against an observable, these live options will update the widget or respond to updates from interactions with the widget.
enabled

Determines if users can interact with the field

isReadOnly

Controls whether the field allows input

value

The current value of the field

widget

If specified, will populate an observable with a reference to the actual widget