Skip to content

Commit

Permalink
v1.2.1: Fixed maxlength html property
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrej Kabachnik committed Jul 17, 2015
1 parent f5850ae commit cd7a43a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions HISTORY.md
@@ -1,3 +1,6 @@
### v1.2.1
* Fixed maxlength parameter for the numpad display. Additionally it is now inherited from the original input field (target).

### v1.2
* Added <code>onChange</code> callback and corresponding <code>numpad.change</code> event triggered every time the user changes the value displayed on the keypad.
* Pressing done now triggers a change event on the target input - just like regular keyboard typing would do
Expand Down
6 changes: 4 additions & 2 deletions jquery.numpad.js
Expand Up @@ -9,7 +9,7 @@
* Project home:
* https://github.com/kabachello/jQuery.NumPad
*
* Version: 1.2
* Version: 1.2.1
*
*/
(function($){
Expand Down Expand Up @@ -113,6 +113,7 @@
});

nmpd.setValue = function(value){
if (nmpd.display.attr('maxLength') < value.length) value = value.substr(0, nmpd.display.attr('maxLength'));
nmpd.display.val(value);
nmpd.trigger('numpad.change', [value]);
};
Expand All @@ -127,7 +128,7 @@
}
nmpd.hide();
nmpd.trigger('numpad.close');
if (target.prop("tagName") == 'INPUT'){
if (target && target.prop("tagName") == 'INPUT'){
target.trigger('change');
}
return nmpd;
Expand All @@ -139,6 +140,7 @@
} else {
if (target.prop("tagName") == 'INPUT'){
nmpd.display.val(target.val());
nmpd.display.attr('maxLength', target.attr('maxLength'));
} else {
nmpd.display.val(parseFloat(target.text()));
}
Expand Down

0 comments on commit cd7a43a

Please sign in to comment.