Skip to content Skip to sidebar Skip to footer

Disable Submit Button If All Three Of Three Specific Dropdown Fields Are Empty

There are four dropdowns in the form. One is optional. Of the other three, at least one has to be chosen. I have a script that I'm using on a form with one field, that disables sub

Solution 1:

jsFiddle Demo here

The three selects you must test can each have a class (something like require_one).

When any select box is changed, check if it has that class. If so, then remove the disabled attribute from the Select button.

Example code:

$('#mySubmit').attr('disabled','disabled');

$('select').change(function(){
    if ( $(this).hasClass('require_one') ){
        $('#mySubmit').removeAttr('disabled');
    }
});

For your own code, try reducing it to just this and see if it works:

$(document).ready(function() {
    $('#sseomodal-submit').attr('disabled', 'disabled');

    $('[id^=sseomodal]').change(function() {
        var myId = $(this).attr('id');
        if (myId == 'sseomodal-level' || myId == 'sseomodal-username' || myId == 'sseomodal-logged') {
            $('#sseomodal-submit').removeAttr('disabled');
        }
    });

}); // END document.ready

Post a Comment for "Disable Submit Button If All Three Of Three Specific Dropdown Fields Are Empty"