Your search did not match any results.
Number Box



This demo shows how to specify the currency, accounting, percent and other formats using the format option. It makes the NumberBox not only format the display value, but also control the user input.

Copy to CodePen
window.onload = function() { var viewModel = { currencyFormat: { format: "$ #,##0.##", value: 14500.55 }, accountingFormat: { format: "$ #,##0.##;($ #,##0.##)", value: -2314.12 }, percentFormat: { format: "#0%", value: 0.15, step: 0.01 }, fixedPointFormat: { format: "#,##0.00", value: 13415.24 }, weightFormat: { format: "#0.## kg", value: 3.14 } }; ko.applyBindings(viewModel, document.getElementsByClassName("demo-container")[0]); };
<!DOCTYPE html> <html xmlns=""> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src=""></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <script src=""></script> <link rel="stylesheet" type="text/css" href="" /> <link rel="stylesheet" type="text/css" href="" /> <script src=""></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div class="dx-fieldset"> <div class="dx-field"> <div class="dx-field-label">Currency format</div> <div class="dx-field-value"> <div data-bind="dxNumberBox: currencyFormat"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Accounting format</div> <div class="dx-field-value"> <div data-bind="dxNumberBox: accountingFormat"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Percent format</div> <div class="dx-field-value"> <div data-bind="dxNumberBox: percentFormat"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Fixed point format</div> <div class="dx-field-value"> <div data-bind="dxNumberBox: fixedPointFormat"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Weight format</div> <div class="dx-field-value"> <div data-bind="dxNumberBox: weightFormat"></div> </div> </div> </div> </div> </body> </html>
.value-positive .dx-texteditor-input { color: #4bb94b; } .value-negative .dx-texteditor-input { color: #ff5f5e; } .dx-field { margin-bottom: 20px; }