I am creating a form and i want the input tag to accept numbers only and i also want to limit the numbers to be from 0 - 20.
This my html code:
<input type="text" name="three" class="actual" id="three" maxlength="2" onkeypress="return ForNumbers(event)" />
This is my javascript code:
<script type="text/javascript">
function ForNumbers(evt){
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>