Associative array:
var signUpStates = {
"CNPJ": false,
"PASSWORDS": false,
"ADDRESS": false,
"GENERAL_FIELDS": false,
"TERMS": false,
}
My attempt:
function updateButton() {
var tempArray = []
$.each(signUpStates, function(i, val) {
tempArray.push(val);
});
if(tempArray.every(function(e, i, a) { return e == true; })) {
$(".btn-cadastrar-fornecedor").attr('disabled', false);
} else {
$(".btn-cadastrar-fornecedor").attr('disabled', true);
}
}
Iterating over it and checking individually does not work. What's the best approach to do such a test?
.all()function, depending on which lib you are using