If I use a <div>
, what should I use as a replacement for the <input>
available on forms?
It is acceptable to include <input>
outside of <form>
.
Having said that, I would usually use a <form>
so that you can bind to its onsubmit
event, instead of worrying about people pressing Enter to submit the form and what events that are generated (which depends on the browser and the form contents ) It is better to mark the form as a form and allow the browser to apply its usual behavior similar to the form than to chase around trying to fake it.
Ideally, to make progressive improvement properly, you should first create a form without JavaScript, so there will actually be something useful to indicate action
. Then add the / XMLHttpRequest scripts on top. If you must have a form that works only with a script, you can add it to the page with the script so that it does not appear to users who are not JS users, and they are not confused when trying to submit it.
source share