[intro]     [up]

Class SizeLimit


The SizeLimit is not a mask for limiting wich chars are typed, but to limit the size of a TextArea, that does not have a default way to do this.
It can use another element as the output for the current status, like how many characters were typed, how much are left, the maximum number of chars, or a custom text containing any combination of them, along with a free text.
Additionally, as well as the other masks, the SizeLimit also uses the KeyUp and Blur events, allowing additional callbacks for these events.

Example
//Assume there is a input and a div on the document
new SizeLimit("input", 50, "div", "${size} / ${max}");


Constructor Arguments
Name Type Default Description
control HTML Input   The input, normally a TextArea
maxLength Numeric   The allowed text length
output HTML Element Not used The element that will display the status text
outputText String &{left} The text that will be outputted. A free String can be used, allowing the following placeholders: &{left} (size left), &{size} (current size) and &{max} (max size)
updateFunction Function null Callback function used when the status is updated (text is changed). The arguments passed to the function are: The control, the text size, the maximum size and the number of characters left
keyUpFunction Function null Callback function for the keyup event
blurFunction Function null Callback function for the blur event
keyDownFunction Function null Callback function for the keydown event
keyPressFunction Function null Callback function for the keypress event

Properties
blurFunction Callback function for the blur event
control The input, normally a TextArea
keyDownFunction Callback function for the keydown event
keyPressFunction Callback function for the keypress event
keyUpFunction Callback function for the keyup event
maxLength The allowed text length
output The element that will display the status text
outputText The text that will be outputted
updateFunction Callback function used when the status is updated (text is changed)

Methods
update Updates the SizeLimit status, refreshing the output element and calling the UpdateFunction



Properties
blurFunction
Callback function for the blur event
control
The input, normally a TextArea
keyDownFunction
Callback function for the keydown event
keyPressFunction
Callback function for the keypress event
keyUpFunction
Callback function for the keyup event
maxLength
The allowed text length
output
The element that will display the status text
outputText
The text that will be outputted. A free String can be used, allowing the following placeholders: &{left} (size left), &{size} (current size) and &{max} (max size)
updateFunction
Callback function used when the status is updated (text is changed). The arguments passed to the function are: The control, the text size, the maximum size and the number of characters left





Methods
 
update
Updates the SizeLimit status, refreshing the output element and calling the UpdateFunction. This method should be called if the input value is modified programatically, or if the updateFunction is set after the constructor