Whenever i paste text in textarea , it should strip the character like <,>,@ etc. i try in JQuery
$('input').on('paste', function () { var element = this; setTimeout(function () { var text = $(element).val(); // do something with text }, 100); });
$('input').on('paste', function () { var element = this; setTimeout(function () { var text = $(element).val(); text.replace('<', '') ); }, 100); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <textarea id="test" name="test" style="height:300px; width:400px"></textarea>
You are using input
element selector which matches only elements with tagname as input
like <input type="..." />
, instead of textarea
so
$('textarea').on('paste', function() { var $el = $(this); setTimeout(function() { $el.val(function(i, val) { return val.replace(/[<>@]/g, '') }) }) });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <textarea id="test" name="test" style="height:300px; width:400px"></textarea>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.