NumericTextBox

Description

The NumericTextBox widget allows for editing a variety of numeric value types.

Official Kendo UI NumericTextBox documentation

Examples

  • Basic Example
  • Passing additional options
  • Using global options

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

<input data-bind="kendoNumericTextBox: price" />
<hr/>
Price: <strong data-bind="text: price"> </strong>
var ViewModel = function() {
   this.price = ko.observable(10.50);
};

                            ko.applyBindings(new ViewModel());

Price:

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

<input type="checkbox" data-bind="checked: enabled" /> Enabled<br/>
<input class="input-mini" data-bind="value: min" /> Min<br/>
<input class="input-mini" data-bind="value: max" /> Max<br/>
<hr/>
<input data-bind="kendoNumericTextBox: { value: price, enabled: enabled, min: min, max: max, format: 'c' }" />
<hr/>
Price: <strong data-bind="text: price"> </strong>
var ViewModel = function() {
   this.price = ko.observable(10.50);
   this.enabled = ko.observable(true);
   this.min = ko.observable(0);
   this.max = ko.observable(100);
};

                            ko.applyBindings(new ViewModel());
Enabled
Min
Max


Price:

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

<input type="checkbox" data-bind="checked: enabled" /> Enabled<br/>
<hr/>
<input data-bind="kendoNumericTextBox: { value: price, enabled: enabled }" />
<hr/>
Price: <strong data-bind="text: price"> </strong>
var ViewModel = function() {
   this.price = ko.observable(10.50);
   this.enabled = ko.observable(true);
};

ko.bindingHandlers.kendoNumericTextBox.options = {
   min: 0,
   max: 100,
   format: 'c'
};

                            ko.applyBindings(new ViewModel());
Enabled


Price:

Live Options

The kendoNumericTextBox.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

min

The minimum value allowed in the field

max

The maximum value allowed in the field

value

The current value of the field

widget

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