<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Capture text pasted into / cut from a text field with JQuery</title> <script src="jquery-3.1.1.min.js"></script> <style type="text/css"> #txt_complaint { width: 300px; margin: 10px; height: 30px; left: calc(50% - 150px); position: absolute; } </style> </head> <body> <input type="text" id="txt_complaint"/> <script type="text/javascript"> $("#txt_complaint").bind('paste', function(e) { var elem = $(this); setTimeout(function() { var text = elem.val(); alert("Value=" + text); }, 10); }); $("#txt_complaint").bind('cut', function(e) { var elem = $(this); setTimeout(function() { var text = elem.val(); alert("Value=" + text); }, 10); }); </script> </body> </html>
Showing posts with label cut. Show all posts
Showing posts with label cut. Show all posts
Saturday, December 17, 2016
Capture text pasted into / cut from a text field with JQuery
Subscribe to:
Posts (Atom)