fix observeInput logic
This commit is contained in:
parent
a0fe77fe66
commit
6df63373ab
@ -158,12 +158,17 @@ var RVR = {
|
||||
document.getElementById('cover').style.visibility = 'hidden';
|
||||
},
|
||||
|
||||
observeInput: function (input, buttonToToggle) {
|
||||
if (input.defaultValue !== input.value) {
|
||||
buttonToToggle.disabled = false;
|
||||
} else {
|
||||
buttonToToggle.disabled = true;
|
||||
observeInput: function (form, observedInputs) {
|
||||
var anyChanged = false;
|
||||
|
||||
for (var i = 0; i < observedInputs.length; i++) {
|
||||
var input = form.elements[observedInputs[i]];
|
||||
if (input.defaultValue !== input.value) {
|
||||
anyChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
form.elements.submit.disabled = !anyChanged;
|
||||
},
|
||||
|
||||
observeInputsInForm: function (form, observedInputs) {
|
||||
@ -174,12 +179,12 @@ var RVR = {
|
||||
case 'INPUT':
|
||||
case 'TEXTAREA':
|
||||
input.oninput = function () {
|
||||
RVR.observeInput(this, form.elements.submit);
|
||||
RVR.observeInput(form, observedInputs);
|
||||
};
|
||||
break;
|
||||
case 'SELECT':
|
||||
input.onchange = function () {
|
||||
RVR.observeInput(this, form.elements.submit);
|
||||
RVR.observeInput(form, observedInputs);
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user