The changes made to fix the Bug were:
Thiago Lunardi’s tip: No longer accepts the letter F, but continues to accept the " ' ".
$(".input-numeric").numeric({
decimal: false,
negative:false
});
Jquery Numeric (Old): Accepted " ' "
$.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 locks 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 block 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 = "";
}
}
};
Good afternoon Thiago, would it be nice to explain this difference to the author right? I hope you take this as a constructive criticism :) - I recommend you read: http://answall.com/help/how-to-answer - Being brief is acceptable, but more thorough explanations are better.
– Guilherme Nascimento
@Thiago Lunardi, got it, you’re right, it really works, but the " ' " is still allowed, Gypsy Morrison Mendez said it’s a bug of the Numeric package, but I can’t use Type="Number" because the number has incompatibilities with IE9... Thanks for the help I’ll try to block the " ' ".
– AleBabaloff
@Guilhermenascimento, I gave an increase. Thank you.
– Thiago Lunardi
Thiago was fine, but I didn’t understand: every string is FALSE, what does this mean? This makes no sense, could it explain? (ps: It was not I who denied your answers)
– Guilherme Nascimento