We can validate textbox with only numbers by writing this Javascript code and calling at onkeypress event of text box
<!–
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
//–>
<asp:TextBox ID=”txt_maxage” Onkeypress=”return isNumberKey(event)” runat=”server”></asp:TextBox>
Blogged with Flock
Tags: asp.net
Superb!!
Thanks!
Nice Sample
Nice one….
I want the user to enter . for decimal place. How to do this.
Code is quite good.
Thanks!
yutyu
thanks
thank u …
Thank you
I have one question
why you input “charCode > 31” to condition because
“charCode 57” it ok
It works fine!
I added attributes in codebehind file;
it too woks good
Thanks so much… super
thank you very much
I want using javascript
very useful
In my page it is not working.. please help
Hi Amit,
What is the problem you are facing. Please let me know clearly/
Thanks!!!!!