javascript - Submit form from a button tag -
i added event listener when form submitted, code:
var formo = document.getelementbyid("ing"); formo.addeventlistener("submit", validation, false);
but i'm submitting form button tag code:
var enviar = document.getelementbyid("submit_btn"); enviar.addeventlistener("click", envioformulario, false); function envioformulario() { this.disabled = true; this.value = "sending"; this.form.submit(); }
with form submitted submit event (the first lines of code) doesn't seems work can create work?
i agree @mathletics comment. validation when click, , submit if passes validation:
var enviar = document.getelementbyid("submit_btn"); enviar.addeventlistener("click", envioformulario, false); function envioformulario() { if (validation()) { this.disabled = true; this.value = "sending"; this.form.submit(); } else { alert("validation failed. didn't submit"); } }
javascript html forms events submit
No comments:
Post a Comment