Actually, $('#field').val() is an *empty string* if a form field is present but empty. So the problem is the test is too type-specific (and testing for the wrong type) already.
You could use != '', but it's cleaner to simply not do any comparison. Code it like this: if( $('#equipmentNumber').val() && $('#description').val() && $('#type').val() && $('#department') && $('#location').val() ) { $('#submit').attr( 'disabled', false ); } Or, if you wanted to explicitly set the disabled attribute in both the true and false case, here's an interesting way to code it: $('#submit').attr( 'disabled', !( $('#equipmentNumber').val() && $('#description').val() && $('#type').val() && $('#department') && $('#location').val() ) ); -Mike > From: Alexandre Plennevaux > > try using !== instead of != as this checks also against the > variable type. > > you can also try > > if ( typeof myvar ==='undefined'){ > //error > } > > From: Chuk > > > > Hi. I have a form with a disabled submit button when the page is > > loaded. I'm trying to activate that submit button only > when two text > > fields(ids="equipmentNumber" and "description") and three > select boxes > > (ids="type","department"," and "location") contain a value. > Here is > > my current code: > > > > if ($('#equipmentNumber').val() != null && > $('#description').val() != > > null && $('#type').val() != null && $('#department') != null && $ > > ('#location').val() != null) > > { > > $('#submit').attr("disabled",false); > > } > > > > However, this condition is always true...even if each field > is blank. > > Does anyone see right off where I've messed up? >