Suppose, you have a textbox where you want a user can enter only numerical values, then write the following script method inside the head section of your page.
<script type="text/javascript">
<script type="text/javascript">
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which :
event.keyCode;
if (charCode > 31 && (charCode < 48 ||
charCode > 57))
return false;
return true;
}
</script>
Then,call this method in the "onkeypress" event of your textbox.
<asp:TextBox ID="txtPhoneNo" runat="server" onkeypress="return isNumberKey(event)">
</asp:TextBox>
Now, as a result the user can not enter any non-numeric value into that textbox.
Regards,
Prajanuranjan....
No comments:
Post a Comment