Check our online training feedbacks Here

12 December 2010

Allow numeric values only in input field using jQuery


$("#input1").keypress(function(e)
{
  // allow digits only
  if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57))
  {
    return false;
  }
});

5 comments :

  1. If you type SHITF+1|3|4|8 then
    result: !#$(

    ReplyDelete
  2. If you type SHITF+1|3|4|8 then
    result: !#$(

    ReplyDelete
  3. That code doesn't work when you set values with SHIFT + 1|3|4|8 something like "!#$("

    ReplyDelete

Your comments, Feedbacks and Suggestions are very much valuable to me :)