Hi All,
people wants to call a function when user paste in the text box, below sample code will help you to achieve the required.By using the jquery it can be too simple -
Example there is sample text box -
< input type="text" id="inpux-box"/>"
$(function(){
$('#inpux-box').bind('paste', function (e) {
setTimeout(function(){textOnKeyPress();}, 50);
});
});
function textOnKeyPress(){
//write ur logic here
}
In the above example if user paste anything in the text box then it will call the function textOnKeyPress().Here setTimeout functions says the after 50 milisecond call the textOnKeyPress(), in this function u can get the pasted value also
if user want to prevent the paste function then he/she can use below code
$(function(){
$('#inpux-box').bind('paste', function (e) {
return false;
});
});
No comments:
Post a Comment