From 694f4bdfd2103b18dc2449de8c349502a0d91505 Mon Sep 17 00:00:00 2001 From: Philipp Matthias Schaefer Date: Sun, 14 Mar 2021 21:48:41 +0100 Subject: [PATCH] feat(js): abort request and show message if any field is empty --- src/static/webldappasswd.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/static/webldappasswd.js b/src/static/webldappasswd.js index de8ab1e..8772f47 100644 --- a/src/static/webldappasswd.js +++ b/src/static/webldappasswd.js @@ -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; });