In this article i will show you how you can restrict your user to add only a number in an asp.net textbox. This will also help you to restrict user to enter only digits or mobile number in textbox using javascript.
Allow Only Numbers
Here is the code to perform this operation.
function CheckNumber(evt)
{
var charcode=(evt.which)?evt.which:event.keycode;
if(charcode>31 && (charcode < 48 || charcode >57 ))
{
return false;
}else
{
return true;
}
}
Allow only number
Here is the javascript code which is responsible for allowing adding only number in a textbox.
function CheckNumber(evt)
{
var charcode=(evt.which)?evt.which:event.keycode;
if(charcode>31 && (charcode < 48 || charcode >57 ))
{
return false;
}else
{
return true;
}
}
Tags: Ajax Control , Asp.Net , Ext Js , Javascript , jQuery , jQuery Mobile , MVC
No comments:
Post a Comment
Note: only a member of this blog may post a comment.