Catch paste input

后端 未结 17 2094
名媛妹妹
名媛妹妹 2020-11-22 08:09

I\'m looking for a way to sanitize input that I paste into the browser, is this possible to do with jQuery?

I\'ve managed to come up with this so far:



        
17条回答
  •  遥遥无期
    2020-11-22 08:26

    OK, just bumped into the same issue.. I went around the long way

    $('input').on('paste', function () {
      var element = this;
      setTimeout(function () {
        var text = $(element).val();
        // do something with text
      }, 100);
    });
    

    Just a small timeout till .val() func can get populated.

    E.

提交回复
热议问题