how is make a jquery validdata number ? (i not use of plugin)
description: i want input text accept only number.
<input type="text" name"number">
how is make a jquery validdata number ? (i not use of plugin)
description: i want input text accept only number.
<input type="text" name"number">
I think this question is already asked.In there are also answers not using plugin.I take it from here How to allow only numeric (0-9) in HTML inputbox using jQuery?
jQuery.fn.ForceNumericOnly =
function()
{
return this.each(function()
{
$(this).keydown(function(e)
{
var key = e.charCode || e.keyCode || 0;
// allow backspace, tab, delete, arrows, numbers and keypad numbers ONLY
return (
key == 8 ||
key == 9 ||
key == 46 ||
(key >= 37 && key <= 40) ||
(key >= 48 && key <= 57) ||
(key >= 96 && key <= 105));
});
});
};
$("#yourTextBoxName").ForceNumericOnly();