Enable / Disable Inpt Form Using Radio Button

Enable / Disable Inpt Form Using Radio Button

by Ahmad Najiullah

HTML

<div> 
                 <input type="radio" checked="checked" name="co" data-for="s" /> 
                 <input type="hidden" id="s" /> Tidak Ada Foto<br /><br /> 
 
                    <input type="radio" name="co" data-for="u"/> 
                    <input type="file" id="u" disabled="disabled" /><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pilih gambar yang ingin di upload
                </div> 
 <br/>
Visit My Site: <a rel="follow" href="http://ahmad.najiullah.com" title="http://najiullah.com" target="_blank">http://ahmad.najiullah.com</a>

JavaScript

$("input[type='radio']").click(function() {
    $("input[type='file']").attr("disabled", "disabled");
    if ($(this).next().attr("disabled") == "disabled") $(this).next().removeAttr("disabled");
    else $(this).next().attr("disabled", "disabled");

});