Input number only using javascript
By bryan tugade
We can validate if numeric key has been press using javascript, then return a message if non numeric has been pressed. We can use keycode to know what keys has been press in the keyboard.
<Script type="text/javascript">
function NumericValidation()
{
if (event.keyCode >= 48 && event.keyCode <= 57){
event.returnValue = true;
}
else
{
event.returnValue=false;
alert("Please input numeric value.");
}
}
</script>
just put the function on onkeypress of your html controls to validate.
i.e.
<input id="inputid " onkeypress="Numeric();">
Related FAQs
We can count how many characters left on keypress using javascript. Here's how.
We can determine what key has been pressed using javascript event.
We can hover on gridview row using javascript onmouseover event. We can also change the color in code behind.
We can hover on gridview row using javascript onmouseover event. We can also change the color in code behind.
Input number only using javascript (1010 Views)