jQuery EasyUI Form Plugin - Numberbox
jQuery EasyUI Plugins
Extends $.fn.validatebox.defaults. Override the default defaults via $.fn.numberbox.defaults.
The numberbox lets users enter only numeric values. It can convert the input element into different input types (such as numeric, percentage, currency, and so on). More input types depend on the 'formatter' and 'parser' functions to be defined.
Depends on
- validatebox
Usage
Create a numberbox from markup.
Create a numberbox using JavaScript.
$('#nn').numberbox({
min:0,
precision:2
});
property
This property extends from the validatebox; the following are properties added for the numberbox.
| Name | Type | Description | Default value |
|---|---|---|---|
| disabled | boolean | Defines whether 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 (number of digits) displayed after the decimal point. | 0 |
| decimalSeparator | string | The character that separates the integer and fractional parts of a number. | . |
| groupSeparator | string | The character that groups the integer part of a number. | |
| prefix | string | The prefix string. | |
| suffix | string | The suffix string. | |
| filter | function(e) | Defines how to filter pressed keys; return true to accept the input character. Available since version 1.3.3. | |
| formatter | function(value) | The function used to format the numberbox value. Returns the string value displayed in the box. | |
| parser | function(s) | The function used to parse a string. Returns the numberbox value. |
Events
| Name | Parameters | Description |
|---|---|---|
| onChange | newValue,oldValue | Triggered when the field value changes. |
Method
This method extends from the validatebox; the following are methods added or overridden for the numberbox.
| Name | Parameters | Description |
|---|---|---|
| options | none | Return the options object. |
| destroy | none | Destroys the numberbox object. |
| disable | none | Disables the field. |
| enable | none | Enables the field. |
| fix | none | Fixes the value to a valid one. |
| setValue | none | Sets the value of the numberbox. |
代码实例:
$('#nn').numberbox('setValue', 206.12);| onSelect | event | getValue | none | Get the value of the number box (numberbox).
Code example:
var v = $('#nn').numberbox('getValue');
alert(v);
| onSelect | event | clear | none | Clear the value of the number box (numberbox).| onSelect | event | reset | none | Reset the value of the number box (numberbox). This method is available since version 1.3.2. |
jQuery EasyUI Plugins