I have a form that the user can submit using either
<input type="submit" name="delete" value="delete" id="deletebutton" class="pure-button">
or
<input type='submit' id="submitbutton" name="btnSubmit" value="save" class="pure-button pure-button-primary">
I have an event listener that on submit
loads a certain function I need to process the form:
document.querySelector('#submitform').addEventListener('submit', function(e) {
e.preventDefault();
// Some code goes here
}
However, this code only reacts when btnSubmit
is clicked. When delete
is clicked the form submits as usual.
How do I avoid that and have another function listening to whether delete
is clicked?
Thank you!
Aucun commentaire:
Enregistrer un commentaire