Re: Does "form" element *really* require an "action" attribute?

Ed Cannon wrote:
> 
> Monday, Oct. 23
> 
> Hi,
> 
> This is to ask if there might possibly be some sort of mistake
> in the HTML 4.01 specification regarding the FORM element:
> 
>  http://www.w3.org/TR/html401/interact/forms.html#h-17.3
> 
> Does it really *require* the "action" attribute?  The reason I
> ask is that someone has told me that when an "onsubmit"
> attribute is present, no "action" is necessary. 

The onsubmit attribute lets authors cause a script
to be executed on form submission. This script needn't 
have anything to do with submitting the form data to
a server, and it shouldn't since HTML has a well-defined 
attribute for doing so: action.

> I don't know
> enough about it to be sure beyond two facts:  (1) the HTML
> 4.01 specification *says* that "action" is required 

Yes.

> but (2)
> some of our code (which I did not write, as I would not know
> how) seems to work just fine without it. 

The 'action' attribute is required for your document to
validate to HTML 4.01. Whether the form "works" (i.e.,
sends data to a server) is a separate question. 
It's possible to do about anything with a script, but you
shouldn't do everything with a script. You should use
appropriate markup.

> (The only reason I
> have gotten as far as asking about this is due to using online
> validators such as the W3C's own to validate our code.)

In conclusion, I don't think this a bug in the HTML specification.

 - Ian

-- 
Ian Jacobs (jacobs@w3.org)   http://www.w3.org/People/Jacobs
Tel:                         +1 831 457-2842
Cell:                        +1 917 450-8783

Received on Monday, 23 October 2000 20:16:30 UTC