开发者

javascript enable/disable textfield/file field onfocus event problem on google chrome

 Use default: 
 <input type="radio" name="restype" value="resdef" onfocus="docu开发者_StackOverflowment.getElementById('resupload').disabled = true; document.getElementById('resadres').disabled = true;" checked="checked" /><br />

 Adres: 
 <input type="radio" name="restype" value="resadres" onfocus="document.getElementById('resupload').disabled = true; document.getElementById('resadres').disabled = false;" /> 
 <input type="text" name="resadres" id="resadres" disabled="disabled" /><br /><br />

 Upload: 
 <input type="radio" name="restype" value="resupload" onfocus="document.getElementById('resadres').disabled = true;  document.getElementById('resupload').disabled = false;" /> 
 <input type="file" name="resupload" id="resupload" disabled="disabled" />

This code works in firefox and IE but not in Chrome. Where is the problem?


onfocus works when you use tab key to navigate. You should use onchange event for form elements.

http://jsfiddle.net/5NaH5/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜