开发者

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

开发者 https://www.devze.com 2023-03-12 03:29 出处:网络
Use default: <input type=\"radio\" name=\"restype\" value=\"resdef\" onfocus=\"docu开发者_StackOverflowment.getElementById(\'resupload\').disabled = true; document.getElementById(\'resadres\').d
 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

精彩评论

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