function onlynumbers(event) {
if (event.keyCode == 46 || event.keyCode == 8) {
return true;
}
else {
// Ensure that it is a number and stop the keypress
if ((event.keyCode < 48 || event.keyCode > 57)) {
alert('enter only numbers....');
return false;
}
else {
return true;
}
}
this function can be written the the TextBox keypress event like
onkeypress="return onlynumbers(event)"
No comments:
Post a Comment