jQuery: Textbox Numbers Only

HTML

Number : <input type="text" name="quantity" id="quantity" />&nbsp;<span id="errmsg"></span>

 jQuery code

$(document).ready(function () {
  $("#quantity").keypress(function (e) {
     if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
        $("#errmsg").html("Digits Only").css("color","red").show().fadeOut("slow");
               return false;
    }
   });
});

 

Artikel terkait:   Audio Player: Responsive and Touch-Friendly

Isi Komentar

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

+ 32 = forty one

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top