fix observeInput function
This commit is contained in:
parent
a1b0f5e9fb
commit
ea8b46ab91
@ -183,12 +183,23 @@ var MapGuesser = {
|
||||
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.type === 'checkbox') {
|
||||
if (input.defaultChecked !== input.checked) {
|
||||
anyChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (input.defaultValue !== input.value) {
|
||||
anyChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
form.elements['submit_button'].disabled = !anyChanged;
|
||||
},
|
||||
|
||||
observeInputsInForm: function (form, observedInputs) {
|
||||
@ -199,19 +210,19 @@ var MapGuesser = {
|
||||
case 'INPUT':
|
||||
case 'TEXTAREA':
|
||||
input.oninput = function () {
|
||||
MapGuesser.observeInput(this, form.elements.submit);
|
||||
MapGuesser.observeInput(form, observedInputs);
|
||||
};
|
||||
break;
|
||||
case 'SELECT':
|
||||
input.onchange = function () {
|
||||
MapGuesser.observeInput(this, form.elements.submit);
|
||||
MapGuesser.observeInput(form, observedInputs);
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
form.onreset = function () {
|
||||
form.elements.submit.disabled = true;
|
||||
form.elements['submit_button'].disabled = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -29,7 +29,7 @@
|
||||
<input type="password" class="text big fullWidth marginTop" name="password_new_confirm" placeholder="New password confirmation" autocomplete="new-password" minlength="6">
|
||||
<p id="accountFormError" class="formError justify marginTop"></p>
|
||||
<div class="right marginTop">
|
||||
<button type="submit" name="submit" disabled>Save</button>
|
||||
<button type="submit" name="submit_button" disabled>Save</button>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="center">
|
||||
|
@ -26,7 +26,7 @@
|
||||
<?php endif; ?>
|
||||
<p id="deleteAccountFormError" class="formError justify marginTop"></p>
|
||||
<div class="right marginTop">
|
||||
<button class="red marginRight" type="submit" name="submit">Delete account</button><!--
|
||||
<button class="red marginRight" type="submit" name="submit_button">Delete account</button><!--
|
||||
--><a class="button gray marginTop" href="/account" title="Back to account">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
|
Loading…
Reference in New Issue
Block a user