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>
<SCRIPTlanguage=Javascript>
<!--
function isNumberPressed(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
returnfalse;
returntrue;
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<INPUTid="txtChar"onkeypress="return isNumberPressed(event)"type="text"name="txtChar">
</BODY>
</HTML>
Hope this helps.
--
Happy Coding
Gopinath
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>
<SCRIPTlanguage=Javascript>
<!--
function isNumberPressed(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
returnfalse;
returntrue;
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<INPUTid="txtChar"onkeypress="return isNumberPressed(event)"type="text"name="txtChar">
</BODY>
</HTML>
Hope this helps.
--
Happy Coding
Gopinath