Yes, however if any of the fields are not empty, this will validate and set the submit button to be enabled.
Try something like this instead.
$(document).ready(function() {
$('#submit_button').attr('disabled', 'disabled');
var isValid = true;
$.each(':input', function() {
if ($(this).val() == "") {
isValid = false;
break;
}
});
if(isValid){
$('#submit_button').removeAttr('disabled');
}
else{
alert('You have empty fields.');
}
});
stbuchok
Practically a Posting Shark
875 posts since May 2011
Reputation Points: 138
Solved Threads: 124
Skill Endorsements: 2
Question Answered as of 3 Months Ago by
gon1387
and
stbuchok