Javascript allow only numeric paste

后端 未结 3 1768
梦谈多话
梦谈多话 2021-01-07 11:35

Javascript/jQuery:

 $(document).ready(function () {
     $(\'#txt\').bind(\"paste\", function (e) {
         var $this = $(this);
         $         


        
3条回答
  •  攒了一身酷
    2021-01-07 12:29

    Call the function onchange event of Textbox as, instead of document.ready:

    HTML

    
    

    JQuery

        function onlyNum() {
          var $this = $('#txt');
          $this.val($this.val().replace(/\D/g, ''));
        }
    

提交回复
热议问题