validate textbox with only numbers using Javascript code

10 03 2008

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:


Actions

Information

One response to “validate textbox with only numbers using Javascript code”

24 04 2008
Sagar (21:02:44) :

Superb!!
Thanks!

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>