feat(js): abort request and show message if any field is empty

This commit is contained in:
Philipp Matthias Schaefer 2021-03-14 21:48:41 +01:00
parent aaec961560
commit 694f4bdfd2

View File

@ -25,6 +25,11 @@ MODAL_STATES = {
message : "Password changed",
icon_url : "checkmark.svg",
},
"FillAllFields" : {
button_disabled : false,
message : "You have to fill all three input fields",
icon_url : "cross.svg",
},
"FetchError" : {
button_disabled : false,
message : "An error occurred while contacting the server",
@ -82,6 +87,11 @@ function clearFields() {
function changePasswords() {
const query = {};
if(!fields().every(field.value.length != 0)) {
showModal("FillAllFields");
return;
}
fields().forEach(field => {
query[field.name] = field.value;
});