黑客版本是在它的位置显示一个假的表单字段,它被禁用(灰色的样式)和onClick,隐藏并显示正确的字段启用,但这是丑陋的.
示例代码
这样做:
<input type="text" id="date_end" value="blah" onClick="this.disabled=true;">
这样做:
<label for="date_end_off" onClick="document.getElementById('date_end').disabled=false">Test</label> <input type="text" id="date_end" value="blah" onClick="alert(1);" disabled>
这失败了:
<input type="text" id="date_end" value="blah" onClick="alert(1);" disabled>
这失败了:
<input type="text" id="date_end" value="blah" onClick="document.getElementById('date_end').disabled=false" disabled>
解决方法
http://www.webdeveloper.com/forum/showthread.php?t=186057
Firefox,and perhaps other browsers,
disable DOM events on form fields that
are disabled. Any event that starts at
the disabled form field is completely
canceled and does not propagate up the
DOM tree. Correct me if I’m wrong,but
if you click on the disabled button,
the source of the event is the
disabled button and the click event is
completely wiped out. The browser
literally doesn’t know the button got
clicked,nor does it pass the click
event on. It’s as if you are clicking
on a black hole on the web page.
解决:
>将日期字段的样式看起来像是他们被禁用>隐藏“use_date”表单域用一点值来确定是否在处理期间使用日期字段.>添加新功能到onClick的日期字段将会更改样式类出现启用并设置“use_date”值到1.