I have a simple contact form, but I want to disable the submit button until both inputs are not empty anymore. I read a lot of answers about kind of the same problem, but they all get answered in jQuery, but I would like to use native JavaScript. How can I achieve this? And can it check if the button should be enabled after any kind of change to the inputs, like pasting?
$(document).ready(function() {
var $submit = $("#verzend"),
$inputs = $('#textarea, #email');
function checkEmpty() {
return $inputs.filter(function() {
return !$.trim(this.value);
}).length === 0;
}
$inputs.on('keyup blur', function() {
$submit.prop("disabled", !checkEmpty());
}).keyup();
});
I found this as a good solution, but it is in JQuery