I have a rule that appears to be formatted like the answer in this thread, but does not validate properly. If I comment out this rule, the validation is performed properly on the rest of the form. Other syntax errors I have found caused the same outcome, so I expect that there is a syntax error here, but durned if I can spot it.
The rule is
freq: {
required: {
depends: {function(element){
return $('#freqBand').val().length > 0 &&
$('#freqBand').val() != "24GHz");
}
}
}
},
I am expecting that if the input field freqBand (a select input) value is anything other than "24GHz" or nothing, then the freq field is required.
I am just learning jquery, so it may be a real forehead-slapper.
EDIT 11/28
I have done some more troubleshooting and have found that $('#freqBand').val() is undefined.
it is found in the HTML as
<select name="freqBand" tabindex="6">
<option value="" label="–Choose–" >–Choose–</option>
<option value="27MHz" label="27 MHz" >27 MHz</option>
<option value="50MHz" label="50 MHz" >50 MHz</option>
<option value="75MHz" label="75 MHz" >75 MHz</option>
<option value="24GHz" label="2.4 GHz" >2.4 GHz</option>
</select>
The query validate docs say that the correct syntax for the select element should be
$("select.freqBand option:selected").val()
but that also resolves to undefined. Does this added information help someone to help me out?