UI Widgets NumberBox

A textbox widget that enables a user to enter numeric values.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/number_box
NumberBox interactive configuration
Copy code
$("#numberbox").dxNumberBox({
});

The NumberBox widget allows a user to enter a number between the specified min and max configuration option values.

You can create a widget using one of the following approaches.

  • jQuery
    Use the dxNumberBox jQuery plug-in.

    HTML
    <div id="numberBox"></div>
    JavaScript
    $("#numberBox").dxNumberBox({
        min: 0,
        max: 100,
        showSpinButtons: true,
        step: 5
    });
  • Knockout
    Add a div element and apply the dxNumberBox binding to this element.

    HTML
    <div data-bind="dxNumberBox: {
        min: 0,
        max: 100,
        showSpinButtons: true,
        step: 5
    }"></div>
  • AngularJS
    Add a div element and apply the dx-number-box directive to this element.

    HTML
    <div dx-number-box="{
        min: 0,
        max: 100,
        showSpinButtons: true,
        step: 5
    }"></div>

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the Installation article.

You can find detailed information on the principles of working with the widget in the dxNumberBox section of the Editor Widgets article.

View Demo

Show Example:
AngularJS
Knockout
jQuery
<div ng-controller="demoController">
    <div class="numberBox" ng-model="number" dx-number-box="{
        min: 0,
        max: 100,
        showSpinButtons: true,
        step: 5
    }"></div>
    <p>The current value is <b>{{number}}</b>.</p>
</div>
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
    $scope.number = 0;
});
angular.element(document).ready(function () {
    angular.bootstrap(document, ['myApp']);
});
body{
    text-align: center;
}
.dx-numberbox{
    margin: 10px;
}
<div class="numberBox" data-bind="dxNumberBox: {
    min: 0,
    max: 100,
    showSpinButtons: true,
    step: 5,
    value: number
}"></div>
<p>The current value is <b data-bind="text: number"></b>.</p>
var myViewModel = {
    number: ko.observable(0)
}
ko.applyBindings(myViewModel);
body{
    text-align: center;
}
.dx-numberbox{
    margin: 10px;
}
<div class="numberBox" id="myNumberBox"></div>
<p>The current value is <b id="valueField">0</b>.</p>
$("#myNumberBox").dxNumberBox({
    min: 0,
    max: 100,
    showSpinButtons: true,
    step: 5,
    value: 0,
    onValueChanged: function (e) {
        $("#valueField").text(e.value);
    }
});
body{
    text-align: center;
}
.dx-numberbox{
    margin: 10px;
}

Configuration

An object defining configuration options for the NumberBox widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.