I have a input box and need to accept just numbers.
I use
javascriptand it works fine but the problem : when the box is empty or deleting numbers it returns false and the box color get red.
Here is the codes:
<input id="amount" type="number" size="7" name="amount" onkeypress='return isNumberKey(event)' required/>
<script type="text/javascript">
function isNumberKey(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>