Hi,
In most of web applications, we get requirement to allow only number in a textbox.
Here is the JavaScript for it, just call this method onKeyPressv Event.
<HTML>
<HEAD>
<SCRIPT language=Javascript>
<!–
function isNumberPressed(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode 57))
return false;
return true;
}
//–>
</SCRIPT>
</HEAD>
<BODY>
<INPUT id=”txtChar”onkeypress=”return isNumberPressed(event)” type=”text” name=”txtChar”>
</BODY>
</HTML>
Hope this helps.
—
Happy Coding
Gopinath