It is necessary when you click on a certain radiobutton to block some fields.

function agreeForm() { if (#autoVK.checked){ #countryVK.disabled = 1; } if(#settingsVK.checked){ #countryVK.disabled = 0; } 

Here such code for some reason does not work. The fields themselves

 <label class="radio-inline"> <input name="typeVK" id="autoVK" value="1" checked="" type="radio" onclick="agreeForm();">АвтоматичСский </label> <label class="radio-inline"> <input name="typeVK" id="settingsVK" value="0" type="radio" onclick="agreeForm();">Π‘ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Π°ΠΌΠΈ </label> <input id="countryVK" type="text" class="form-control" placeholder="Π‘Ρ‚Ρ€Π°Π½Π°" style="width:120px"> 

    1 answer 1

    Using jquery :

     $("#countryVK").attr("disabled","disabled"); $(".control").change(function(){ if($(this).val()=="1"){ $("#countryVK").attr("disabled","disabled").val(''); }else{ $("#countryVK").removeAttr("disabled"); } }); 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <label class="radio-inline"> <input name="type" id="autoVK" value="1" class="control" checked="" type="radio"> АвтоматичСский </label> <label class="radio-inline"> <input name="type" id="settingsVK" value="0" type="radio" class="control" >Π‘ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Π°ΠΌΠΈ </label> <input id="countryVK" type="text" class="form-control" placeholder="Π‘Ρ‚Ρ€Π°Π½Π°" style="width:120px">