Revision: 63664
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 27, 2013 20:20 by keidash
Initial Code
$('[id$=txtControl]').bind('keypress', function (e) {
onlyNumbers(e);
});
function onlyNumbers(e) {
var result = true;
var items = [9, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57];
var code = (e.keyCode ? e.keyCode : e.which);
$.each(items, function () {
if (code == this) {
result = false;
}
});
if (result == true) {
e.preventDefault();
}
}
Initial URL
Initial Description
Example to manipulate only numbers (and tab key) in a web control (textbox example)
Initial Title
Only Numbers in Web Controls with jQuery
Initial Tags
number, jquery
Initial Language
jQuery