最佳实践形式检查 [英] best-practice form checking

查看:65
本文介绍了最佳实践形式检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了这个表单,这样如果Javascript被禁用,它将会显示一个典型的< input type =" submit">按钮,但使用< noscript>

标记。为什么这是一个问题,什么是可行的解决方案?我不确定

最好的方法,所以非常感谢帮助;讽刺,

smartass,无益的评论毫无用处。请自己保留


解决方案

cruiserweight写道:

我构建了这个表单,这样如果Javascript被禁用,它将显示一个典型的< input type =" submit">按钮,但使用
< noscript>标签。为什么这是一个问题,什么是可行的解决方案?


问题是为什么你这样做了。为什么在no-js情况下只提供一个提交按钮



snide,smartass,无用的评论都没用。请保持好自己。



最好不要采取态度,特别是在你得到任何帮助之前。


-

Brian(删除.invalid给我发电子邮件)


ba ***** @ yahoo.com (cruiserweight)写道:

我已经构建了这个表单所以如果Javascript被禁用,它将显示典型的< input type =" submit">按钮,但使用< noscript>
标签。


启用JavaScript的用户会怎样?他们是否得到了一个

提交按钮?


以什么方式让一些用户受益_不是立即获得

可识别的提交按钮?

为什么这是一个问题,什么是可行的解决方案?


< noscript>是一个钝器。如果用户的浏览器支持

JavaScript但不支持需要的所有单个部分,那么该怎样才能用来做你所做的任何事情。干嘛?

我不确定
最好的方法,所以非常感谢帮助;




使用服务器端脚本在HTML中编写表单,该脚本完全处理

提交(包括需要完成的任何检查)。


然后添加JavaScript最重要的是执行客户端检查

(节省的时间将使那些启用了JS的人受益)。这个


JavaScript应该通过

表单的onsubmit事件处理程序(或等效的事件监听器方法)触发,而不是通过onclick事件触发

特定按钮的处理程序等。


此JavaScript也应编写,以便浏览器回退

将表单提交给服务器在JavaScript无法处理
的情况下 - 如果在数据中检测到

明确错误,它应该只提交表单。


关于JS的技术问题会更好地针对

comp.lang.javascript


Steve


-

我的理论给你起见,我的异端邪说激怒你,

我从不回信,你也不喜欢我的领带。 - 医生


Steve Pugh< st *** @ pugh.net> < http://steve.pugh.net/>


ba * ****@yahoo.com (cruiserweight)写道:

我已经构建了这个表单,这样如果Javascript被禁用它会显示一个典型的< input type =" submit">按钮,但使用< noscript>
标签。为什么这是一个问题,什么是可行的解决方案?我不确定最好的方法,所以非常感谢帮助; snide,
smartass,无益的评论都没用。


这是一个聪明的人,因此没用,只要一个心灵可以帮助你,如果你保持/>
麻烦造成代码的秘密?

请保持好自己。




我''我非常抱歉浪费了你的时间,但我无法抗拒b
抵抗。我们现在可以通过在没有提供相关信息的情况下寻求帮助来浪费*我们的*时间

而道歉吗?


-

Harlan Messinger

从我的电子邮件地址中删除第一个点。

Veuillez?ter le premier point de mon adresse de courriel。


I''ve constructed this form so that if Javascript is disaabled it will
show a typical <input type="submit"> button, BUT using the <noscript>
tag. Why is this a problem and what''s a viable solution? i''m not sure
of the best way to do this so help is very much appreciated; snide,
smartass, unhelpful comments are useless. Please keep them to
yourself.

解决方案

cruiserweight wrote:

I''ve constructed this form so that if Javascript is disaabled it
will show a typical <input type="submit"> button, BUT using the
<noscript> tag. Why is this a problem and what''s a viable solution?
The question is why you''ve done this. Why is a submit button only
available in no-js situations?
snide, smartass, unhelpful comments are useless. Please keep them
to yourself.


Best not to cop an attitude, especially before you''ve gotten any help.

--
Brian (remove ".invalid" to email me)


ba*****@yahoo.com (cruiserweight) wrote:

I''ve constructed this form so that if Javascript is disaabled it will
show a typical <input type="submit"> button, BUT using the <noscript>
tag.
What happens for users who do have JavaScript enabled? Do they get a
submit button at all?

In what way does it benefit some users _not_ to have an instantly
recognisable submit button?
Why is this a problem and what''s a viable solution?
<noscript> is a blunt instrument. What if the user''s browser supports
JavaScript but doesn''t support all the individual parts that need to
be used to do whatever it is that you''re doing?
i''m not sure
of the best way to do this so help is very much appreciated;



Write the form in HTML with a server side script that handles the
submission fully (including any checking that needs to be done).

Then add JavaScript on top of that to perform client side checking
(the time saved will benefit those who have JS enabled). This

JavaScript should be triggered via the onsubmit event handler of the
form (or equivalent event listener methods), not via the onclick event
handler of a particular button, etc.

This JavaScript should also be written so that the browser falls back
to submitting the form to the server in cases where the JavaScript can
not be processed - it should only ever not submit the form if a
definite error is detected in the data.

Technical questions on JS would be better directed to
comp.lang.javascript

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don''t like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>


ba*****@yahoo.com (cruiserweight) wrote:

I''ve constructed this form so that if Javascript is disaabled it will
show a typical <input type="submit"> button, BUT using the <noscript>
tag. Why is this a problem and what''s a viable solution? i''m not sure
of the best way to do this so help is very much appreciated; snide,
smartass, unhelpful comments are useless.
Is it being a smartass, and therefore useless, to bring to your
attention the fact that only a psychic can help you if you keep the
trouble-causing code a secret?
Please keep them to
yourself.



I''m so profoundly sorry for having wasted your time, but I couldn''t
resist. May we now have *your* apologies for having wasted *our* time
by asking for help without providing relevant information?

--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ?ter le premier point de mon adresse de courriel.


这篇关于最佳实践形式检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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