Code Sample:
<html>
<head>
<title>allwon only numbers in textbox using JavaScript</title>
<script language="Javascript" type="text/javascript">
function onlyNos(e, t) {
try {
if (window.event) {
var charCode = window.event.keyCode;
}
else if (e) {
var charCode = e.which;
}
else { return true; }
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
catch (err) {
alert(err.Description);
}
}
</script>
</head>
<body>
<table align="center">
<tr>
<td>
<input type="text" onkeypress="return onlyNos(event,this);" />
</td>
</tr>
</table>
</body>
</html>
No comments:
Post a Comment