From 9238bacc555bd8f71d74f43197f5244e4d834bd5 Mon Sep 17 00:00:00 2001 From: JesLabs Date: Mon, 13 Apr 2015 15:01:39 +0200 Subject: [PATCH] Negative sign is ignored When there is already a negative value in the input, if you select all the value and type negative sign, it's ignored (keypress event return false). --- numeric/jquery.numeric.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numeric/jquery.numeric.js b/numeric/jquery.numeric.js index 3410238..a5de58a 100644 --- a/numeric/jquery.numeric.js +++ b/numeric/jquery.numeric.js @@ -87,7 +87,7 @@ $.fn.numeric.keypress = function(e) { var value = $(this).val(); /* '-' only allowed at start and if negative numbers allowed */ - if($.inArray('-', value.split('')) !== 0 && negative && key == 45 && (value.length === 0 || parseInt($.fn.getSelectionStart(this), 10) === 0)) { return true; } + if (key == 45 && negative && ($.inArray('-', value.split('')) !== 0 || value.length === 0 || parseInt($.fn.getSelectionStart(this), 10) === 0)) { return true; } /* only one decimal separator allowed */ if(decimal && key == decimal.charCodeAt(0) && $.inArray(decimal, value.split('')) != -1) {