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.
*/
if (ev && ev.preventDefault) { ev.preventDefault(); }
var $empty_inputs = this.$('input.required:emptyVal');
if ($empty_inputs.length) {
$empty_inputs.addClass('error');
return;
}
var has_empty_inputs = _.reduce(document.querySelectorAll('input.required'),
function (result, input) {
if (input.value === '') {
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])'),
iq = $iq({type: "set"}).c("query", {xmlns:Strophe.NS.REGISTER});

View File

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