Using querySelectorAll
as suggested by @JanDvorak (and his answer should be accepted for thinking of that), you can write your own expression, making .is(':invalid')
valid ?
jQuery.extend(jQuery.expr[':'], {
invalid : function(elem, index, match){
var invalids = document.querySelectorAll(':invalid'),
result = false,
len = invalids.length;
if (len) {
for (var i=0; i<len; i++) {
if (elem === invalids[i]) {
result = true;
break;
}
}
}
return result;
}
});
now you can do :
if( $(e.target).is(':invalid') ){ ... }
FIDDLE
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…