const validateForm = () => { $('input').each(function() { const $this = $(this); const $button = $('button'); if ($this.val() === '' || $this.val().length <= 0) { $button.attr('disabled', 'disabled'); } else if (!$button.attr('disabled')) { $button.removeAttr('disabled'); } }) } $('input').on('input', validateForm);