Change button class when ALL fields are selected
I'm trying to execute a script where, when all select fields have been selected the submit button becomes active and the user can send.
Beforehand though, I want the button inactive (working) and a class adding called 'inactive'.
What I'm finding is, once one of the (four) selects has been selected the class gets removed and can't understand why as the button stays inactive until all four have been selected....
- jQuery('.stage_two_btn').attr('disabled', true).addClass('inactive');
- jQuery('.product_lead_class, .product_length_class, .product_width_class, .product_depth_class').on('change', function () {
-
- var product_lead_class = jQuery(".product_lead_class").val();
- var product_length_class = jQuery(".product_length_class").val();
- var product_width_class = jQuery(".product_width_class").val();
- var product_depth_class = jQuery(".product_depth_class").val();
- if (product_lead_class != '' && product_length_class != '' && product_width_class != '' && product_depth_class != '') {
- jQuery('.stage_two_btn').attr('disabled', false).addClass('inactive');
- } else {
- jQuery('.stage_two_btn').attr('disabled', true).removeClass('inactive');
- }
- });