Accept only numeric character with BACKSPACE and TAB button facility.
When you enter some numeric value in age or amount like textbox then you not need to enter any other character. there are lot of script available in the internet about this. but they don't support BACKSPACE and TAB button facility. here are listed below code will support BACKSPACE and TAB button facility.
<input type="text" id="roll" name="roll" onkeypress="checkNumeric(
<script>
function checkNumeric(e) {
if (window.event) { // IE
if(e.keyCode==13 || e.keyCode==0 || e.keyCode==8) {
event.returnValue = true;
return true;
}
if ((e.keyCode < 48 || e.keyCode > 57) & e.keyCode != 8) {
event.returnValue = false;
return false;
}
} else { // FF
if(e.which==13 || e.which==0 || e.which==8) {
return true;
}
if ((e.which < 48 || e.which > 57) & e.which != 8) {
e.preventDefault();
return false;
}
}
}
</script>
0 comments:
Post a Comment