I have a couple of divs with the same class on one page that have a form with input fields and a submit button in them. I check with jquery for each input field if it is empty, and I want the submit button in that specific div to be disabled when theres an empty field in that div. Got this so far:
jQuery(document).ready(function(){
$('.shipdiv input').each(function(){
if( $(this).val() == ''){
$(this).css("background-color","#ff0000");
$(this).parent('.contact-button').attr('disabled', 'disabled');
}
});
});
When theres a field empty it colors red, and then I try to disable the submitbutton that is in its parent. But thats not working. Anyone got an idea on how to do this?
HTML looks somthing like this:
<div class="shipdiv">
<form name="order_002" method="post" action="">
<input type="textfield" class="ship_data" name="bedrijfsnaam"/>
<input type="textfield" class="ship_data" name="straat" />
<input type="textfield" class="ship_data" name="postcode"/>
<input type="submit" name="ship-submit" id="ship-submit" class="contact-button" value="Aanmelden">
</form>
</div>
And then with several of these divs.