I have to use here jquery keyup to detect if user enter any text or not, but my problem is if user use paste the text using mouse, it won't be able to detect it, can you tell me the reason?
here is my source code:
$("textarea").keyup(function(){ if($(this).val().length !== 0){ $('#submit').attr('disabled',false);
Apparently there are some situations where jQuery doesn't work for pasting. You might need to bind to several events as shown in following reference to catch users pasting contents accurately.
From Soliciting Fame - jQuery keyup vs bind - (from way-back machine)
// detect the change $('input#myId').bind("change keyup input",function() { // handle events here });
UPDATE: bind
was deprecated on Jquery 3.0 and was replaced with on
// detect the change $('input#myId').on("change keyup input",function() { // handle events here });
In this particular situation enough will be just bind to the input event:
$('textarea').bind("input", function() {});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With