[intro]     [up]

Class NumberMask


A mask for numbers.
Is uses a NumberParser to format the data. A single parser may (and should!) be used for multiple mask instances.
The parser supports input both from right to left or from left to right. On left to right, the integer part is filled first, and the user must type a decimal separator to enter on decimal part. On right to left, the decimal part is filled first, and, when it's complete, the integer part is filled. On this mode, the parser MUST have the decimalDigits property greater or equals than zero - unlimited decimal size is not supported on right to left filling.
The NumberParser handles numbers using a parser to read the format parameters from it, but does not parses the number. On prior versions, the text was parsed, so the JavaScript precision limited the number length. But, the method getAsNumber() may return a rounded number if the control text represents a number larger than the JavaScript maximum precision allows.

Example
//Assume there is a input on the document
var parser = new NumberParser(2, ",", ".", true);
var mask = new NumberMask(parser, "number");
mask.keyUpFunction = function (event) {
    alert(debug(event));
}


Constructor Arguments
Name Type Default Description
parser NumberParser   The NumberParser used to parse/format/validate data
control HTML Input   The input to mask
maxIntegerDigits Number -1 The maximum integer digits allowed. -1 Means no limit. It only counts real digits (separators, currency symbol, etc, not counted)
allowNegative boolean The value of the JST_DEFAULT_ALLOW_NEGATIVE constant Allow negative numbers?
keyPressFunction Function null Callback function for the keypress event
keyDownFunction Function null Callback function for the keydown event
keyUpFunction Function null Callback function for the keyup event
blurFunction Function null Callback function for the blur event
updateFunction Function null Callback function called whenever the mask is applied. The mask reference is passed on the call
leftToRight boolean The value of the JST_DEFAULT_LEFT_TO_RIGHT constant Will the input be from left to right (true) or right to left (false)?

Properties
allowNegative Allow negative numbers?
blurFunction Callback function for the blur event
control The input to mask
keyDownFunction Callback function for the keydown event
keyPressFunction Callback function for the keypress event
keyUpFunction Callback function for the keyup event
leftToRight Will the input be from left to right (true) or right to left (false)?
maxIntegerDigits The maximum integer digits allowed
parser The NumberParser used to parse/format/validate data
updateFunction Callback function called whenever the mask is applied

Methods
getAsNumber Returns the control value as a Number
setAsNumber Sets the control value as a Number
update Forces the mask to be applied on the control



Properties
allowNegative
Allow negative numbers?
blurFunction
Callback function for the blur event
control
The input to mask
keyDownFunction
Callback function for the keydown event
keyPressFunction
Callback function for the keypress event
keyUpFunction
Callback function for the keyup event
leftToRight
Will the input be from left to right (true) or right to left (false)?
maxIntegerDigits
The maximum integer digits allowed. -1 Means no limit. It only counts real digits (separators, currency symbol, etc, not counted)
parser
The NumberParser used to parse/format/validate data
updateFunction
Callback function called whenever the mask is applied. The mask reference is passed on the call





Methods
 
getAsNumber
Returns the control value as a Number
 
setAsNumber
Sets the control value as a Number
Arguments
Name Type Default Description
number Number   The value as a Number
 
update
Forces the mask to be applied on the control