// Numeric operators only control handler
jQuery.fn.ForceNumericOnly =
function () {
return this.each(function () {
$(this).keydown(function (e) {
var key = e.charCode || e.keyCode || 0;
var text = $(this).val();
// allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
// home, end, period, and numpad decimal
if (e.shiftKey === true) {
return false;
}
if (key == 190 || key == 110) {
if (text.indexOf(".") >= 0) {
return false;
}
}
return (
key == 8 ||
//key == 16 ||
key == 9 ||
key == 46 ||
key == 110 ||
key == 190 ||
(key >= 35 && key <= 40) ||
(key >= 48 && key <= 57) ||
(key >= 96 && key <= 105));
});
});
};
jQuery.fn.ForceNumericOnly =
function () {
return this.each(function () {
$(this).keydown(function (e) {
var key = e.charCode || e.keyCode || 0;
var text = $(this).val();
// allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
// home, end, period, and numpad decimal
if (e.shiftKey === true) {
return false;
}
if (key == 190 || key == 110) {
if (text.indexOf(".") >= 0) {
return false;
}
}
return (
key == 8 ||
//key == 16 ||
key == 9 ||
key == 46 ||
key == 110 ||
key == 190 ||
(key >= 35 && key <= 40) ||
(key >= 48 && key <= 57) ||
(key >= 96 && key <= 105));
});
});
};
No comments:
Post a Comment