button.disabled - firefox vs IE的区别 [英] button.disabled - firefox vs IE difference

查看:55
本文介绍了button.disabled - firefox vs IE的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



您好,我们在按钮上输入以下代码:


< input type =" button"类= QUOT; BTN"值= QUOT;继续] onclick =" if

(myform.p_name.value =='''')alert(''你必须输入文件夹''的名称);

else {this.disabled = true;提交();}">


并非所有验证都可以在客户端执行,因此按下按钮可能会按下
,然后服务器验证是执行 - 这可能会导致

请求用户点击后退按钮并更正一些数据

输入。


现在这不是最好的UI设计,我知道。但是,我们必须坚持使用这个用于qhile的
并且我注意到了方式上的差异

Fireforx和IE处理按钮disbaling。在IE上,当你回到

页面时,按钮再次启用,而在Firefox中则保持灰色

并禁用。


当用户按下后退按钮时,是否有人可以建议我们自动重新启用

按钮的方式?是否有一些代码我们可以将

放入onload中,这些代码将通过

表格中的所有按钮并启用它们?


感谢您的建议。


-


jeremy


Hi, say we have the code below on a button:

<input type="button" class="btn" value="Continue" onclick="if
(myform.p_name.value=='''') alert(''You must enter a name for the folder'');
else { this.disabled=true; submit();}">

Not all the validation can be performed client-side so the button may be
pressed and then server validation is performed - this may result in a
request to the user to hit the back button and correct some data
entered.

Now this isn''t the best UI design, I know. But nonetheless we have to
stick with this for a qhile and I have noticed a difference in the way
Fireforx and IE handles the button disbaling. On IE, when you go back to
the page, the button is enabled again whereas in Firefox it remains grey
and disabled.

Can anyone suggest a way in which we can automatically re-enable the
button when the user presses the back button? Is there some code we can
put into the onload perhaps which will go through all buttons on the
form and enable them?

Appreciate your suggestions.

--

jeremy

推荐答案

Jeremy写道:
Jeremy wrote:
< input type =" button"类= QUOT; BTN"值= QUOT;继续] onclick =" if
(myform.p_name.value =='''')alert(''你必须输入文件夹''的名称);
else {this.disabled = true;提交();}">


这是废话,见下文。

并非所有验证都可以在客户端执行,因此可以按下按钮然后按服务器执行验证 - 这可能会导致用户点击后退按钮并更正输入的一些数据。


这会有什么问题?你的应用程序应该能够

处理。

现在这不是最好的UI设计,我知道。但是,我们必须坚持使用这个来获得


完全没有。

我注意到Fireforx和Fireforx的区别IE处理
按钮disbaling。在IE上,当你回到页面时,按钮再次启用,而在Firefox中它仍然是灰色并且被禁用。

任何人都可以建议我们可以自动重新启用的方式用户按下后退按钮时的
按钮?是否有一些我们可以放入onload的代码可能会通过
表单上的所有按钮并启用它们?
<input type="button" class="btn" value="Continue" onclick="if
(myform.p_name.value=='''') alert(''You must enter a name for the folder'');
else { this.disabled=true; submit();}">
This is nonsense, see below.
Not all the validation can be performed client-side so the button may be
pressed and then server validation is performed - this may result in a
request to the user to hit the back button and correct some data
entered.
And what would be wrong with this? Your application should be able to
handle that anyway.
Now this isn''t the best UI design, I know. But nonetheless we have to
stick with this for a qhile
Not at all.
and I have noticed a difference in the way Fireforx and IE handles the
button disbaling. On IE, when you go back to the page, the button is
enabled again whereas in Firefox it remains grey and disabled.

Can anyone suggest a way in which we can automatically re-enable the
button when the user presses the back button? Is there some code we can
put into the onload perhaps which will go through all buttons on the
form and enable them?




No.您/必须/重新考虑您的设计。特别是:


1.使用提交按钮,即输入[type =" submit"],输入[type =" image"],

或按钮[type =" submit"](后两者不向后

兼容)。这样用户就可以在没有客户端的情况下提交

脚本支持。


2.使用`form'的`onsubmit''事件处理程序'元素,并在那里做表格

验证,通过调用验证函数而不是这个

严重可维护的意大利面条代码。如果你想要提交表单,则将'true''返回给处理程序,否则返回'false'。

的众多例子已经在此发布过。请在发布之前进行最低限度的研究

;它是一个_news_group。


3.使用服务器端会话,这样你可以检测服务器端,如果之前从该客户端收到的数据是
,除非服务器端会话定时

out,或者是积极结束。

PointedEars



No. You /have to/ reconsider your design instead. Especially:

1. Use a submit button, i.e. input[type="submit"], input[type="image"],
or button[type="submit"] (where the latter two are not backwards
compatible). This way users will be able to submit without client-side
script support.

2. Use the `onsubmit'' event handler of the `form'' element, and do the form
validation there, by calling a validation function instead of this
badly maintainable spaghetti code. Return `true'' to the handler if you
want the form to be submitted, `false'' otherwise. Numerous examples of
this have been posted here before. Please do a minimum of research
before you post here; it is a _news_group.

3. Use server-side sessions, so you can detect server-side if data has been
received from that client before, unless the server-side session timed
out, or was actively ended.
PointedEars


在文章< 12****************@PointedEars.de> ;, Thomas''PointedEars''

Lahn说......
In article <12****************@PointedEars.de>, Thomas ''PointedEars''
Lahn says...
不。您/必须/重新考虑您的设计。特别是:

1.使用提交按钮,即输入[type =" submit"],输入[type =" image"],
或按钮[type =" submit" ;](后两者不向后兼容)。这样用户就可以在没有客户端脚本支持的情况下提交。

2.使用`form''元素的`onsubmit''事件处理程序,并执行表单<通过调用验证函数而不是这个可维护性很差的意大利面条代码来验证那里。如果您希望提交表单,则将true返回给处理程序,否则返回false。之前已经发布了很多这样的例子。请在发布之前进行最少的研究
;它是_news_group。

3.使用服务器端会话,因此如果之前已从该客户端收到数据,您可以检测服务器端,除非服务器端会话计时
out,或者是积极结束。
No. You /have to/ reconsider your design instead. Especially:

1. Use a submit button, i.e. input[type="submit"], input[type="image"],
or button[type="submit"] (where the latter two are not backwards
compatible). This way users will be able to submit without client-side
script support.

2. Use the `onsubmit'' event handler of the `form'' element, and do the form
validation there, by calling a validation function instead of this
badly maintainable spaghetti code. Return `true'' to the handler if you
want the form to be submitted, `false'' otherwise. Numerous examples of
this have been posted here before. Please do a minimum of research
before you post here; it is a _news_group.

3. Use server-side sessions, so you can detect server-side if data has been
received from that client before, unless the server-side session timed
out, or was actively ended.



谢谢。我不怀疑你在这里要点的有效性。然而,我是最好的位置,能够确定是否可以在这个阶段重写我们处理某些位的方式
$

编码。该应用程序可供一组封闭的用户使用,我们可以对使用的浏览器进行控制。


短期内,作为hack修复(我对此没有任何瑕疵),它将满足我的需求,只需在页面重新启用按钮时重新启用按钮

在用户之后重新显示按了后退按钮。我想从你上面的

声明中可以看出不,您/必须/重新考虑您的设计。 "我理解你说这不是一个不可取的情况,而是一个不可能的案例 - 是这样吗?


再次感谢


-


jeremy


Thanks. I don''t doubt the validity of the points you are making here. I
however am in the best position to be able to determine whether or not
it is feasible at this stage to rewrite the way we handle certain bits
of coding. The application is available to a closed group of users over
whom we can exercise some control over what browsers are used.

In the short term, as a hack fix (I make no bones about this), it would
meet my needs to be able to simply re-enable the button when the page is
redisplayed after a user has pressed the back button. I think from your
statement above " No. You /have to/ reconsider your design instead. " I
am right in understanding that you are saying that it is not a case of
it not being desirable but a case of it not being possible - is that so?

Thanks again

--

jeremy


虽然我认为你可以重写你的验证方式

他建议在这里发布的时间,我会很好并回答

问题的问题;)


最好的办法是按名称一个接一个地启用按钮,简单地说

onload脚本。如果你正在做一些快速而又脏的事情,那么你也可以获得
。它会工作,它只是不是最漂亮的代码或

最有效的方法。你需要命名你的按钮和表格,

,或参考将是一个真正的痛苦。


有些东西:


< head>

< script>

function mewantbuttons(){

theform.continuebtn.disabled = false;

theform.otherbtns.disabled = false;

}

< / script>

< ; / head>

< body onload =" mewantbuttons()">

< form NAME =" theform">

< input NAME =" continuebtn"类型= QUOT按钮"类= QUOT; BTN" value ="继续>

onclick =" if

(myform.p_name.value =='''')alert(''你必须输入一个名字

文件夹'');

else {this.disabled = true;提交();}">

< / form>


----

那说,我同意托马斯的评估。这将花费你很少的时间来编写你的javascript干净地执行onsubmit。

此外,我倾向于避免自己的javascript验证。如果威胁是
他们将不得不重新输入数据,我有服务器验证给他们他们的数据预先填写在表格中。后退按钮不会

总是给他们回复数据,所以你不应该依赖它。

While I''m of the opinion that you could rewrite your validation the way
he suggested in the time it takes to post here, I''ll be nice and answer
the question as asked ;)

Your best bet is to enable the buttons by name, one after another, in a
simple onload script. If you''re doing something quick and dirty, you
might as well. It will work, its just not the prettiest code or the
most efficient way to do it. You do need to name your button and form,
though, or referencing will be a real pain.

Something along the lines of:

<head>
<script>
function mewantbuttons() {
theform.continuebtn.disabled = false;
theform.otherbtns.disabled = false;
}
</script>
</head>
<body onload="mewantbuttons()">
<form NAME="theform">
<input NAME="continuebtn" type="button" class="btn" value="Continue"
onclick="if
(myform.p_name.value=='''') alert(''You must enter a name for the
folder'');
else { this.disabled=true; submit();}">
</form>

----
That said, I agree with Thomas''s assessment. It will take you very
little time to write your javascript cleanly to act onsubmit.
Also, I tend to avoid javascript validation myself. If the threat is
that they''d have to re-enter data, I have the server validation give
them their data back pre-filled in the form. The back button won''t
always give them their data back, so you shouldn''t rely on it.


这篇关于button.disabled - firefox vs IE的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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