Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Form won't validate without action/method?

Reply
Thread Tools

Form won't validate without action/method?

 
 
Pete
Guest
Posts: n/a
 
      02-11-2004
I have form/select which executes a function using onchange. No
problem. However, when I validate the page with a strict HTML 4.01
doctype at http://validator.w3.org, it demands either an action or a
method for the form?.

If I give it an empty action <form action="" ..... it validates OK. Is
this acceptable or is there a better/standards correct way?

Thanks.
 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      02-11-2004
"Pete" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> I have form/select which executes a function using onchange. No
> problem. However, when I validate the page with a strict HTML 4.01
> doctype at http://validator.w3.org, it demands either an action or a
> method for the form?.
>
> If I give it an empty action <form action="" ..... it validates OK. Is
> this acceptable or is there a better/standards correct way?
>
> Thanks.



I believe that a missing or blank "action=" will default to the current page
and that a missing "method=" will default to "get". If "get" is specifed
(or defaulted to) instead of "post" then, on form submission, the
querystring (which follows the URL) will contain a list of the form fields
and there values.

It's good form to specify both; for example,

<form action="thispage.htm" method="post">


 
Reply With Quote
 
 
 
 
Michael Winter
Guest
Posts: n/a
 
      02-11-2004
On 10 Feb 2004 20:27:22 -0800, Pete <(E-Mail Removed)>
wrote:

> I have form/select which executes a function using onchange. No
> problem. However, when I validate the page with a strict HTML 4.01
> doctype at http://validator.w3.org, it demands either an action or a
> method for the form?.


The action attribute is required and the method attribute defaults to GET.
Specifying 'action=""' will submit the form to the current page.

> If I give it an empty action <form action="" ..... it validates OK. Is
> this acceptable or is there a better/standards correct way?


It would appear that you're only using a form in order to access the form
controls. Is this assumption correct? If so, you should avoid this
practice: it is quite simple to script an interface with form controls,
without actually requiring an enclosing form element. Please post the
code, or provide a URI, if you're interested.

Mike

--
Michael Winter
http://www.velocityreviews.com/forums/(E-Mail Removed)d (replace ".invalid" with ".uk" to reply)
 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      02-11-2004
"Michael Winter" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
<snip>
>It would appear that you're only using a form in order to access
>the form controls. Is this assumption correct? If so, you should
>avoid this practice: it is quite simple to script an interface
>with form controls, without actually requiring an enclosing form
>element. ...


If support for Netscape 4 is relevant then the form is needed, as
otherwise the controls don't display (similarly, without a form HotJava
will show the controls but you can't do anything with them. Not that
anyone in their right mind would use HotJava as a web browser any more).

Certainly once Netscape 4 is gone there will be no need for the form
elements if there is no intention to submit anything. But with a form
the - form - properties of the controls would still provide a convenient
way for controls to refer to each other without having to go to the
document and look each other up by ID. Possibly allowing multiple forms
to implement similar patterns without interfering with each other
(server-side loop generated).

Also, the onsubmit handler might sometimes be a good level at which to
place an event handler even if it had to always return false. And
controls in forms are relatively easy to fall-back to server-side
scripts in the absence of client-side support. While a control outside
of a form is going to be pretty pointless without client-side scripting.

Richard.


 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      02-11-2004
On Wed, 11 Feb 2004 16:16:34 -0000, Richard Cornford
<(E-Mail Removed)> wrote:

> "Michael Winter" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> <snip>
>> It would appear that you're only using a form in order to access
>> the form controls. Is this assumption correct? If so, you should
>> avoid this practice: it is quite simple to script an interface
>> with form controls, without actually requiring an enclosing form
>> element. ...

>
> If support for Netscape 4 is relevant then the form is needed, as
> otherwise the controls don't display (similarly, without a form HotJava
> will show the controls but you can't do anything with them. Not that
> anyone in their right mind would use HotJava as a web browser any more).


Quite right. I forgot about the problems associated with NN4.

> Certainly once Netscape 4 is gone there will be no need for the form
> elements if there is no intention to submit anything. But with a form
> the - form - properties of the controls would still provide a convenient
> way for controls to refer to each other without having to go to the
> document and look each other up by ID. Possibly allowing multiple forms
> to implement similar patterns without interfering with each other
> (server-side loop generated).


True, but I wouldn't like to advocate bad practices like HTML element
abuse just for the purposes of convenience. That is the domain of tables
for layout, and the like.

> Also, the onsubmit handler might sometimes be a good level at which to
> place an event handler even if it had to always return false. And
> controls in forms are relatively easy to fall-back to server-side
> scripts in the absence of client-side support. While a control outside
> of a form is going to be pretty pointless without client-side scripting.


That was why I asked the OP to post code if the question revolved solely
around a UI: to give useful advice, we would need to know what was trying
to be accomplished.

Mike

--
Michael Winter
(E-Mail Removed)d (replace ".invalid" with ".uk" to reply)
 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      02-11-2004
"Michael Winter" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
<snip>
>>... . But with a form the - form - properties of the controls would
>>still provide a convenient way for controls to refer to each other
>>without having to go to the document and look each other up by ID.
>>Possibly allowing multiple forms to implement similar patterns
>>without interfering with each other (server-side loop generated).

>
>True, but I wouldn't like to advocate bad practices like HTML element
>abuse just for the purposes of convenience. That is the domain of
>tables for layout, and the like.


But is it element abuse akin to using tables for layout? As I understand
it the argument with tables is that semantically table implies tabular
data and so is inappropriate for non-tabular data and in almost all
circumstances tables used for layout would not (directly) contain
tabular data.

Among the many definitions of "form" in the first dictionary that came
to hand, the only definition that seemed pertinent was:-

Form:
"A printed document, esp. one with spaces in which to insert facts or
answers: an application form."

We can forget about "printed" in our context and "document" is not the
usual HTML/DOM document, but "with spaces in which to insert facts or
answers" seems very relevant to this context. It implies that the
semantic meaning of FORM is as a container of spaces in which to insert
facts or answers; form controls.

So where is the abuse if form controls are contained in a form,
submitted or not?

I realise that is just one of many possible interpretations and someone
wanting to stress the submitability of a form would point out that it
has a required ACTION attribute and that is fairly meaningless if the
form is not intended to be submitted. But I wouldn't like to rule out a
potentially useful construct just because of a dogma.

<snip>
>... , we would need to know what was trying to be accomplished.


Don't we always?

Richard.


 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      02-11-2004
On Wed, 11 Feb 2004 19:02:39 -0000, Richard Cornford
<(E-Mail Removed)> wrote:

> "Michael Winter" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> <snip>
>>> ... . But with a form the - form - properties of the controls would
>>> still provide a convenient way for controls to refer to each other
>>> without having to go to the document and look each other up by ID.
>>> Possibly allowing multiple forms to implement similar patterns
>>> without interfering with each other (server-side loop generated).

>>
>> True, but I wouldn't like to advocate bad practices like HTML element
>> abuse just for the purposes of convenience. That is the domain of
>> tables for layout, and the like.


[snip]

> Form:
> "A printed document, esp. one with spaces in which to insert facts or
> answers: an application form."
>
> We can forget about "printed" in our context and "document" is not the
> usual HTML/DOM document, but "with spaces in which to insert facts or
> answers" seems very relevant to this context. It implies that the
> semantic meaning of FORM is as a container of spaces in which to insert
> facts or answers; form controls.
>
> So where is the abuse if form controls are contained in a form,
> submitted or not?


Button elements used to initiate script actions? Checkboxes or radio
buttons that affect page behaviour (assuming there is no server-side
support)?

I'm useless at coming up with examples like this, so there might be other,
better uses to illustrate my point. However, neither of the above fit the
definition of a form, would be submittable, and thereby warrant the use of
a form element.

Mike

--
Michael Winter
(E-Mail Removed)d (replace ".invalid" with ".uk" to reply)
 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      02-11-2004
"Michael Winter" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
<snip>
>>Form:
>>"A printed document, esp. one with spaces in which to insert
>>facts or answers: an application form."

<snip>
>>... , but "with spaces in which to insert facts or answers"
>>seems very relevant to this context. It implies that the
>>semantic meaning of FORM is as a container of spaces in which
>>to insert facts or answers; form controls.
>>
>>So where is the abuse if form controls are contained in a form,
>>submitted or not?

>
>Button elements used to initiate script actions? Checkboxes or radio
>buttons that affect page behaviour (assuming there is no server-side
>support)?


Thinking about it I am going to have to concede that a semantic
definition of FORM that considers it a container for from controls would
have to require that there be more than one control and that all of the
controls in a form would have to be related. An isolated control, say a
button, probably isn't any more than a control and that would probably
extend to sets of like-named radio buttons.

But given multiple related controls within a form I don't think that
what those controls actually do is relevant, and I don't think it
matters which type of controls they are. Even buttons are an opportunity
to enter the answer to a question; the question "are you going to press
this button?".

>I'm useless at coming up with examples like this, so there might
>be other, better uses to illustrate my point.


There are plenty of other people to volunteer an opinion.

>However, neither of the above fit the definition of a form, would be
>submittable, and thereby warrant the use of a form element.


So are you saying that form means submittable? It is the crux of the
matter, does semantic mark-up mean what it says or mean what it does?

Richard.


 
Reply With Quote
 
Michael Winter
Guest
Posts: n/a
 
      02-11-2004
On Wed, 11 Feb 2004 20:35:46 -0000, Richard Cornford
<(E-Mail Removed)> wrote:

> "Michael Winter" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> <snip>
>>> Form:
>>> "A printed document, esp. one with spaces in which to insert
>>> facts or answers: an application form."

> <snip>
>>> ... , but "with spaces in which to insert facts or answers"
>>> seems very relevant to this context. It implies that the
>>> semantic meaning of FORM is as a container of spaces in which
>>> to insert facts or answers; form controls.
>>>
>>> So where is the abuse if form controls are contained in a form,
>>> submitted or not?

>>
>> Button elements used to initiate script actions? Checkboxes or radio
>> buttons that affect page behaviour (assuming there is no server-side
>> support)?

>
> Thinking about it I am going to have to concede that a semantic
> definition of FORM that considers it a container for from controls would
> have to require that there be more than one control and that all of the
> controls in a form would have to be related. An isolated control, say a
> button, probably isn't any more than a control and that would probably
> extend to sets of like-named radio buttons.
>
> But given multiple related controls within a form I don't think that
> what those controls actually do is relevant, and I don't think it
> matters which type of controls they are. Even buttons are an opportunity
> to enter the answer to a question; the question "are you going to press
> this button?".


I did consider that as I wrote my previous post.

>> I'm useless at coming up with examples like this, so there might
>> be other, better uses to illustrate my point.

>
> There are plenty of other people to volunteer an opinion.
>
>> However, neither of the above fit the definition of a form, would be
>> submittable, and thereby warrant the use of a form element.

>
> So are you saying that form means submittable?


Not necessarily, but I can't think of anything that I might describe as a
form, that I wouldn't implement as a submittable form. As I pointed out,
creating random examples isn't my forte.

> It is the crux of the matter, does semantic mark-up mean what it says
> or mean what it does?


The former. For example, a DIV should partition a document logically. It
shouldn't be used just because it puts some space above and below the
element, particularly as there is nothing in the specification that says
it should do so.

This then brings us back full-circle: what does 'form' mean, and should
that meaning be the limit of its use? The initial intent would appear to
be for submission to a server, indicated by the required status of the
action attribute, and this, from the Specification:

"Users generally 'complete' a form by modifying its controls...before
submitting the form to an agent for processing."

Based on that, forms shouldn't be used for easy reference, but only if you
mean to send data.

Mike

--
Michael Winter
(E-Mail Removed)d (replace ".invalid" with ".uk" to reply)
 
Reply With Quote
 
Pete
Guest
Posts: n/a
 
      02-11-2004
Michael Winter <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> On 10 Feb 2004 20:27:22 -0800, Pete <(E-Mail Removed)>
> wrote:
>
> > I have form/select which executes a function using onchange. No
> > problem. However, when I validate the page with a strict HTML 4.01
> > doctype at http://validator.w3.org, it demands either an action or a
> > method for the form?.

>
> The action attribute is required and the method attribute defaults to GET.
> Specifying 'action=""' will submit the form to the current page.
>
> > If I give it an empty action <form action="" ..... it validates OK. Is
> > this acceptable or is there a better/standards correct way?

>
> It would appear that you're only using a form in order to access the form
> controls. Is this assumption correct? If so, you should avoid this
> practice: it is quite simple to script an interface with form controls,
> without actually requiring an enclosing form element. Please post the
> code, or provide a URI, if you're interested.
>
> Mike


Thanks Michael.

It's a world clock that I like. It isn't mine and I'm just tidying it
up before using it. The author's original did have (action=" ") but I
couldn't understand why, so I er.. deleted it! Your form assumption is
correct I think. I didn't know you could dump <form> to use its stuff.

Anyway, here's what I'm working from.
http://www.btinternet.com/~kurt.grig...orldclock.html

Pete.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting validator error message to appear without using page.validate darrel ASP .Net 3 03-19-2007 09:26 PM
Validate Document object against Schema without reparsing the xml veerleverbr@hotmail.com Java 2 06-28-2005 07:42 AM
submit form, validate form, set cookie, send email, download file mhawkins19@adelphia.net Javascript 1 03-17-2005 08:19 AM
form wont validate on remote server Jack Wheeler ASP .Net 1 06-14-2004 09:46 PM
Schema validate from DOM Document without reparsing Jean-Marc Vanel XML 0 06-24-2003 11:43 AM



Advertisments