At the following form
:
<form id="form_id" method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" autocomplete="off" onsubmit="valida_form()">
I have a function that checks for blanks:
function valida_form(evt)
{ Array.from(document.getElementById("form_id")).forEach(function(element,index)
{ if(element.value === "")
{ form_err++;
}
});
if(form_err > 0)
{ alert("Há erros:"+form_err);
evt.preventDefault();
}else
{ alert("Sem erro"+form_err);
}
}
meanwhile form
is still being sent.
I'm learning the passage of arguments, and callbacks
so if the error is something related, I appreciate the explanation.