@noutcheu1
Posted
can you please describe what was your probleme ?
@jmahamed
Posted
my problem was that the form would submit and then show the error messages after a few clicks. For example I leave everything blank and try to submit it would take a few clicks for the errors to show up and the form will have submitted anyway. i want to fix that @noutcheu1
@noutcheu1
Posted
@jmahamed I your probleme is you'are not stop the submit of your form just use this pattern first of all define a ID on a form like this
<form action="#form-card" id="Myform" method="get">
// .... //
</form>
and in a js file get this id
let form = document.querySelector("#Myform");
add an new event when you submit form whit addeventlistener methode
form.addEventListener("submit", (event)=>{
event.preventDefault(); // this method stop the the form submit and then you can't do what you want
// stop form submission
// add your code bellow
and if your form it is correct use this methode to send your your
if(send_form){
form.submit();
}
}
});
I hope it will help you .