Vishal Anand Vishal Anand - 2 months ago 5
jQuery Question

jquery paste event not firing if pasted using context menu in chrome

How to detect paste event, if it is triggered by chrome context menu ?
If done using

ctrl + V


following works fine.

$('#txtNumbers').on('keyup paste change', function () {

if ($(this).val() !== '') {
$('#btnAdd').prop('disabled', false);
}
else {
$('#btnAdd').prop('disabled', true);
}
});

Answer

Use the input event

 $('#txtNumbers').on('input', function () {

            if ($(this).val() !== '') {
                $('#btnAdd').prop('disabled', false);
            }
            else {
                $('#btnAdd').prop('disabled', true);
            }
  });
Comments