没有行动/方法,表格将无法验证? [英] Form won't validate without action/method?

查看:48
本文介绍了没有行动/方法,表格将无法验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有form / select使用onchange执行一个函数。没有

问题。但是,当我在 http:来验证页面时使用严格的HTML 4.01

doctype //validator.w3.org
,它要求表格的动作或

方法?


如果我给它一个空行动< form action ="" .....它验证确定。

这个可接受还是有更好/标准的正确方法?


谢谢。

解决方案
"皮特" <所以******************* @ yahoo.co.uk>在消息中写道

新闻:1a ************************* @ posting.google.co m ... < blockquote class =post_quotes>我有form / select使用onchange执行一个函数。没问题。但是,当我在 http:// validator中验证具有严格HTML 4.01
文档类型的页面时。 w3.org
,它要求表单的动作或
方法吗?

如果我给它一个空行动< form action ="" .....它验证确定。
这是可以接受的还是有更好/标准的正确方法?

谢谢。



我相信缺少或空白的动作= "将默认为当前页面

并且缺少method =将默认为获取。如果获得指定

(或默认为)而不是post然后,在表单提交时,

查询字符串(在URL后面)将包含表单字段列表

和值。


指定两者都是好的形式;例如,


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


2004年2月10日20:27:22 -0800,Pete< so *********** ********@yahoo.co.uk>

写道:

我有form / select使用onchange执行一个函数。没问题。但是,当我在 http:// validator中验证具有严格HTML 4.01
文档类型的页面时。 w3.org
,它要求表单的动作或
方法?


action属性是必需的,method属性默认为GET。

指定''action =""''将表单提交给当前页面。

如果我给它一个空行动< form action ="" .....它验证确定。
这是否可接受或是否有更好/标准的正确方法?




看来您只是使用表格才能访问表格

控制。这个假设是否正确?如果是这样,你应该避免这种实践:使用表单控件编写一个接口非常简单,

而不需要实际需要一个封闭的表单元素。如果您有兴趣,请发布

代码或提供URI。


Mike


-

Michael Winter
M.******@blueyonder。 co.inva lid(将.invalid替换为.uk以回复)


" Michael Winter" < M ****** @ blueyonder.co.invalid>。在留言中写道

news:op ************** @ news-text.blueyonder.co.uk ...

< ; snip>

看来您只是使用表单来访问表单控件。这个假设是否正确?如果是这样,你应该避免这种做法:使用表单控件编写一个界面非常简单,而实际上并不需要一个封闭的表单元素。 ...




如果对Netscape 4的支持是相关的,则需要表格,因为

否则控件不显示(类似地,没有表单HotJava

将显示控件,但你不能用它们做任何事情。不是那个

任何心智正常的人都会使用HotJava作为web浏览器了。


当然,一旦Netscape 4消失,如果无意提交任何内容,则不需要表格

元素。但是使用一个表单

- 控件的 - 属性仍然可以为控件提供方便的

方式,而无需转到

文件并按ID查看对方。可能允许多个表单

来实现类似的模式而不会相互干扰

(生成服务器端循环)。


另外,即使必须始终返回false,onsubmit处理程序有时可能是一个很好的级别,即
放置一个事件处理程序。并且在没有客户端支持的情况下,表单中的
控件相对容易回退到服务器端

脚本。虽然在没有客户端脚本的情况下,表单外部的控件将是毫无意义的。


Richard。


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.

解决方案

"Pete" <so*******************@yahoo.co.uk> wrote in message
news:1a*************************@posting.google.co 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">


On 10 Feb 2004 20:27:22 -0800, Pete <so*******************@yahoo.co.uk>
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
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)


"Michael Winter" <M.******@blueyonder.co.invalid> wrote in message
news:op**************@news-text.blueyonder.co.uk...
<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.


这篇关于没有行动/方法,表格将无法验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆