Currently, you can use jquery. on ("copy cut paste", handlerfn) Capture. the setTimeout method is used on the Internet to obtain all the values after the input box is pasted;
The sample code for setTimeout is as follows:
$ ("Input "). off ("Paste "). on ("Paste", function (e) {setTimeout (function () {var val = $ (this ). val (); // obtain and process the value pasted into the input box}, 100 );});
Handlerfn is triggered after "right-click and paste", and "paste value is displayed in the input box". To disable this function, you can use: E. preventdefault () to disable pasting;
According to the MDN introduction, these three types of events are collectively referred to as clipboardevent. In handlerfn, data can be obtained through the getdata method. However, this API currently only supports chrome and firefox22, therefore, it is not widely used;
The sample code is as follows:
$("input").off("paste").on("paste", function(e){ var eData = e.originalEvent.clipboardData; console.log("paste:", arguments, e.originalEvent, eData, eData.types, eData.getData("text/plain"));});
Currently, this type of documentation is called clipboard API and events, and is in the working draft State (working draft );
For details, see:
MDN https://developer.mozilla.org/en-US/docs/Web/Events/paste
W3C draft http://www.w3.org/TR/clipboard-apis/#paste-event
Summary of the capture of copy, cut, and paste in the browser