The changes made to the bug fix were:
Thiago Lunardi's tip: He no longer accepts the letter F, but continues to accept the "'".
$(".input-numeric").numeric({
decimal: false,
negative:false
});
Jquery Numeric (Old): Accepted the "" "
$.fn.numeric.keypress = function(e)
{
// get decimal character and determine if negatives are allowed
var decimal = $.data(this, "numeric.decimal");
var negative = $.data(this, "numeric.negative");
var decimalPlaces = $.data(this, "numeric.decimalPlaces");
// get the key that was pressed
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
// allow enter/return key (only when in an input box)
if(key == 13 && this.nodeName.toLowerCase() == "input")
{
return true;
}
else if(key == 13)
{
return false;
}
//dont allow #, $, %, '
else if(key == 35 || key == 36 || key == 37){
return false;
}
Jquery Numeric (New) has been added to key 39, now blocks the "'":
$.fn.numeric.keypress = function(e)
{
// get decimal character and determine if negatives are allowed
var decimal = $.data(this, "numeric.decimal");
var negative = $.data(this, "numeric.negative");
var decimalPlaces = $.data(this, "numeric.decimalPlaces");
// get the key that was pressed
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
// allow enter/return key (only when in an input box)
if(key == 13 && this.nodeName.toLowerCase() == "input")
{
return true;
}
else if(key == 13)
{
return false;
}
//dont allow #, $, %, '
else if(key == 35 || key == 36 || key == 37 || key == 39){
return false;
}
Jquery Numeric Control + V (Old): Accepted Control + V
$.fn.numeric.blur = function()
{
var decimal = $.data(this, "numeric.decimal");
var callback = $.data(this, "numeric.callback");
var negative = $.data(this, "numeric.negative");
var val = this.value;
if(val !== "")
{
var re = new RegExp("^" + (negative?"-?":"") + "\d+$|^" + (negative?"-?":"") + "\d*" + decimal + "\d+$");
if(!re.exec(val))
{
callback.apply(this);
}
}
};
Jquery Numeric (New): Now blocks Control + V
$.fn.numeric.blur = function()
{
var decimal = $.data(this, "numeric.decimal");
var callback = $.data(this, "numeric.callback");
var negative = $.data(this, "numeric.negative");
var val = this.value;
if(val !== "")
{
var re = new RegExp("^" + (negative?"-?":"") + "\d+$|^" + (negative?"-?":"") + "\d*" + decimal + "\d+$");
if(!re.exec(val))
{
callback.apply(this);
this.value = "";
}
}
};