I have an HTML form with multiple inputs. Some have the class required
.
I want to show the "submit" button once all of these fields have a value.
I tried using:
$(document).ready(function() {
$("#submit_button").hide();
$('.required').on('keyup', function () {
if($(this).val() !== "") {
$("#submit_button").show();
} else {
$("#submit_button").hide();
}
});
});
but this shows the button if just one input is not blank.
Is it possible to do this for multiple inputs, once all the inputs with the required
class are not blank?
CheckRequired function
function CheckRequired(event) {
var $form = $(this);
var emptyElements = $form.find('.required').filter(function() {
return this.value === ''
});
if(emptyElements.length > 0) {
event.preventDefault();
emptyElements.addClass("EmptySelect").attr('title', 'This field is required');
//alert(emptyElements.attr("id"));
alert("One or more fields cannot be blank");
event.stopImmediatePropagation();
return false;
}
}