Form onsubmit is not called at multiple intervals each containing an input
work:
<form class=filter onsubmit="alert('submit');">
<span class=a></span>
<span class=b> <input type=text name=b /> </span>
</form>
does not work:
<form class=filter onsubmit="alert('submit');">
<span class=a></span>
<span class=b> <input type=text name=b /> </span>
<span class=c> <input type=text name=c /> </span>
</form>
By work, what I mean is that when I type some text and hit enter, the onsubmit (simple warning) form is called. Why doesn't it work in the second case? What's the best way to fix this or work around it? I could add a separate onchange event for each html login, or add events via javascript / JQuery. Is this the best approach?
I have a "table" built from divs for rows and spaces for records. The form is one row in the table. Wrapping the inputs inside the slots makes the formatting (mostly column widths / spacing) more uniform. The actual entry element is then set to 80% of the span.
source to share
- You should really wrap your attribute values in
""
s. -
Depending on the browser, the Enter key may only result in a form submit if the form has exactly one text field or only if there is a submit button. To get around this, you can try this with hidden,
input type="submit"
or use a combination of jQuerykeypress
andsubmit
to detect the clickenter
and submit the form programmatically.
source to share
Where is your submit button?
I just tried this in jsfiddle and it worked :
<form class=filter onsubmit="alert('submit');">
<span class=a></span>
<span class=b> <input type=text name=b /> </span>
<span class=c> <input type=text name=c /> </span>
<input type='submit' />
</form>
source to share