Extend from $.fn.validatebox.defaults. Override defaults with $.fn.numberbox.defaults.
The numberbox is used to lets the user only input numberical values. It can convert an input element into different types of input such as numeric, percentage, currency, etc. More types of input can be defined depending on the 'formatter' and 'parser' function.
Create numberbox from markup.
- <input type="text" class="easyui-numberbox" value="100" data-options="min:0,precision:2">
Create numberbox using javascript.
- <input type="text" id="nn">
- $('#nn').numberbox({
- min:0,
- precision:2
- });
The properties extend from validatebox, below is the added properties for numberbox.
Name | Type | Description | Default |
---|---|---|---|
disabled | boolean | Defines if to disable the field. | false |
value | number | The default value. | |
min | number | The minimum allowed value. | null |
max | number | The maximum allowed value. | null |
precision | number | The maximum precision to display after the decimal separator. | 0 |
decimalSeparator | string | The decimal character separates the integer and decimal parts of a number. | . |
groupSeparator | string | The character that separates integer groups to show thousands and millions. | |
prefix | string | The prefix string. | |
suffix | string | The suffix string. | |
filter | function(e) | Defines how to filter the key pressed, return true to accept the inputed char. This property is available since version 1.3.3. | |
formatter | function(value) | A function to format the numberbox value. Return string value that will display on box. | |
parser | function(s) | A function to parse a string. Return numberbox value. |
Name | Parameters | Description |
---|---|---|
onChange | newValue,oldValue | Fires when the field value is changed. |
The methods extend from validatebox, below is the added or overridden methods for numberbox.
Name | Parameter | Description |
---|---|---|
options | none | Return the numberbox options. |
destroy | none | Destroy the numberbox object. |
disable | none | Disable the field. |
enable | none | Enable the field. |
fix | none | Fix the value to valid value. |
setValue | value |
Set numberbox value.
Code example: $('#nn').numberbox('setValue', 206.12); |
getValue | none |
Get numberbox value.
Code example: var v = $('#nn').numberbox('getValue'); alert(v); |
clear | none | Clear numberbox value. |
reset | none | Reset numberbox value. This method is available since version 1.3.2. |