Your code is:
$('.container').children().each(function (index, item2){
if ($(item2).val()=== '' && (item2.tagName.toLowerCase() !== 'label' || item2.tagName.toLowerCase() !== 'span')){
console.log("tag: "+item2.tagName.toLowerCase());
}
});
Here you write your condition :- $(item2).val() === '' && (item2.tagName.toLowerCase() !== 'label' || item2.tagName.toLowerCase() !== 'span')
First of all if you want to allow non-empty value element use !== instead of using === (as @Rory McCrossan suggest).
Now we talk about your second condition i.e. - (item2.tagName.toLowerCase() !== 'label' || item2.tagName.toLowerCase() !== 'span')
means here you allow if element is LABEL OR SPAN.
So, your condition goes into following four ways -
(false || true ) ====> true // Element is label
(true || false ) ====> true // Element is span
(true || true ) ====> true // Element is not a span and not a label
(false || false ) ====> false // Element is a span and also an label [this condition never satisfied]
I think, here you are wrong. You should use following condition (if you don't allow both type of element)-
$(item2).val() === '' && (item2.tagName.toLowerCase() !== 'label' && item2.tagName.toLowerCase() !== 'span')
In short you must use &&/AND instead of using ||/OR.
$(item2).val() !== ''.