add error message when supplied id is wrong

This commit is contained in:
Adrian Amaglio 2020-08-25 09:48:46 +02:00
parent 790f3fcf6f
commit 9e9d393de8

View File

@ -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, {