How do I count select elements, but only where the options value is not blank?
I have a long form in a tabbed interface, where I want to count the non blank fields on each tab (the form fields are text and checkbox inputs and multi & single select fields). The counting function is as follows:
// Input argument is a tab object
function countFieldsOnTab(obj){
var counttext = obj.find('input:text[value!=""]').length;
var countchkbox = obj.find('input[type=checkbox][checked]').length;
var countselect = obj.find('select option:selected').length;
// final count of all
return counttext + countchkbox + countselect;
}
The counts of text, checkbox and multi-select fields works, but the single select count doesn't return what I want. The default option in single selects is a default where the value is blank "<option value="">-- make a selection -- </option>. These will be found as selected options.
How do I count only those options have have a non-blank selection?