B
B
banny_name2015-10-02 21:55:59
JavaScript
banny_name, 2015-10-02 21:55:59

How can I get the id of a submitted form?

I have multiple forms, how do I know which one was submitted?

<form action etc>
input
</form>
<form action etc>
input
</form>

here is all i have JS:
var form = document.querySelectorAll('form');
for(var i=0;i<form.length;i++){
    form[i].addEventListener('submit', validate, false);
}

function validate(){
...
};

I can't find it in target..
+ data-* can't be used..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Zuev, 2015-10-02
@banny_name

It is possible, for example,
where a collection of forms is stored in document.forms , and this is the current form
Example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question