<strong><span style="color: #ff00ff;">This code helps you </span>: in a text box <span style="color: #ff00ff;">only numeric key press</span>,  permission. <span style="color: #ff00ff;">For Run just copy and</span> paste and run it:</strong>

<script>
function validate_for_integers(inputfield, inputevent)
{
var key;
var keychar;

if (window.event) {
key = window.event.keyCode;
} else if (inputevent) {
key = inputevent.which;
} else {
return true;
}

keychar = String.fromCharCode(key);
if ((key==null) || (key==0) || (key==8) ||
(key==9) || (key==13) || (key==27)) {
return true;

} else if (("0123456789").indexOf(keychar) > -1) {
return true;

} else {
return false;
}
}
</script>
<input type="text" class="inputBox" name="phone" onKeyPress="return validate_for_integers(this, event)" onKeyDown="textCounter(this.form.phone, this.form.remLen5,15);"
onkeyup="textCounter(this.form.phone, this.form.remLen5,15); "/>

Share on Facebook