i have an input box(createBIAInput) that enables a save button(saveBtn) when a value has been entered into it. however it doesnt recognize when a value has been pasted into it with a mouse so save button(saveBtn) does get enabled. So i need to know how to enable the save button even when a value as been copied and pasted with a mouse.
FYI it works if you type in the value or you use "control V" to enter value.
$('#createBIAInput').bind('input propertychange', function() {
$('#saveBtn').prop('disabled', false);
});
Use the onpaste
listener, that gets fired when you paste something into the input
, like this:
var input = document.getElementById('createBIAInput'),
button = document.getElementById('saveBtn');
input.addEventListener('paste', function(e) {
button.disabled = false;
});
Or, using jQuery:
$('#createBIAInput').on('paste', function(e) {
$('#saveBtn').prop("disabled", false);
});
So, to enable your button when the users writes or pastes something :
$('#createBIAInput').on('paste keyup', function(e) {
$('#saveBtn').prop("disabled", false);
});
Working example: http://jsfiddle.net/0cfvb9zc/1
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.