From 9e9d393de87de758f870e80cd56c669f9f53ffd0 Mon Sep 17 00:00:00 2001 From: Adrian Amaglio Date: Tue, 25 Aug 2020 09:48:46 +0200 Subject: [PATCH] add error message when supplied id is wrong --- client/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/index.js b/client/index.js index 3efafe8..4709801 100644 --- a/client/index.js +++ b/client/index.js @@ -16,6 +16,10 @@ function interceptForm (formId) { * Param formId is the HTML id of the form */ const formElem = document.getElementById(formId) + if (!formElem) { + console.error('You tried to intercept form id:"' + formId + '" but it was not found.') + return + } formElem.onsubmit = async (e) => { e.preventDefault() fetch(formElem.action, {