HTML validation warning:
lacks “action” attribute (action is needed)

formshtml

I'm using Firefox plugin to validate html errors on the page. It displays a warning:

An HTML tag has a mandatory attribute, but this attribute is missing.

Example:

  • not good: <form>
  • good: <form action="my_action.jsp">

Actually I put the <form></form> tags to give a name to use it as a parameter for javascript function.

The code looks like:

<form name="items">

<select name="selectitem" onchange="displayfunc(this.form)">
<option value="1">one</option>
...
<option value="8">eight</option>
</select>

</form>

Everything works fine, but that warning.. Should I fix it? If yes, then how?

BTW, FF displays "<form> lacks "action" attribute" warning on the stackoverflow page as well. I've found a similar thread required attribute “action” not specified, but I'm still not sure what to do if there is no action="" for the form.

Best Solution

If you don't want users to be able to submit the form, then you shouldn't be using the form element. Use something like <div id="items"></div> instead to contain your input items.

BTW, just because another website does something that violates standards doesn't mean you should. :)