Refactor to not use pseudo jQuery selector ':emptyVal'

This commit is contained in:
JC Brand 2017-03-30 13:48:19 +02:00
parent cb94fd1940
commit 4dd8fa655e
2 changed files with 9 additions and 9 deletions

View File

@ -433,11 +433,15 @@
* (Event) ev - the submit event. * (Event) ev - the submit event.
*/ */
if (ev && ev.preventDefault) { ev.preventDefault(); } if (ev && ev.preventDefault) { ev.preventDefault(); }
var $empty_inputs = this.$('input.required:emptyVal'); var has_empty_inputs = _.reduce(document.querySelectorAll('input.required'),
if ($empty_inputs.length) { function (result, input) {
$empty_inputs.addClass('error'); if (input.value === '') {
return; input.classList.add('error');
} return result + 1;
}
return result;
}, 0);
if (has_empty_inputs) { return; }
var $inputs = $(ev.target).find(':input:not([type=button]):not([type=submit])'), var $inputs = $(ev.target).find(':input:not([type=button]):not([type=submit])'),
iq = $iq({type: "set"}).c("query", {xmlns:Strophe.NS.REGISTER}); iq = $iq({type: "set"}).c("query", {xmlns:Strophe.NS.REGISTER});

View File

@ -63,10 +63,6 @@
return deferred.promise(); return deferred.promise();
}; };
$.expr[':'].emptyVal = function(obj){
return obj.value === '';
};
$.fn.hasScrollBar = function() { $.fn.hasScrollBar = function() {
if (!$.contains(document, this.get(0))) { if (!$.contains(document, this.get(0))) {
return false; return false;