Hello, I have a text area, I want that user's should not be able to enter a charaters in it. I want them to enter only numbers.
I have written the code below to do this but it is not working as I think I am not calling the function right way: can anyone rectify my code:
// Get ASCII value of key that user pressed
var key = window.event.keyCode;
// Was key that was pressed a numeric character (0-9)?
if ( key > 47 && key < 58 )
return; // if so, do nothing
window.event.returnValue = null; // otherwise,
// discard character
<input type="text" name="text" value=""></input>
<input type="button" name="button1" value="Check" onclick="return CheckNumeric();"></input>
I am open to new suggestions as well, if I can show some alert to user if they enter character rather than no.
your help is welcome