javascript - On Check one input gets disabled and the other gets enabled -
i'm coding form gets value search process .. i'm coding 2 text fields user give input on 1 of them.but 1 of them enable @ time .. user can chose option checking check box. default 1 of field should b enable, when check-box checked it(the 1 enable) gets disabled , other gets enabled, , vice versa when check-box unchecked.
here is fiddle:
this fix problem
html :
<input type="text" name="" /> <input type="checkbox" name="" /> <input type="text" name="" disabled="'disabled'"/> js :
$(':checkbox').change(function(){     if ($(this).is(':checked')) {         $(this).prev().attr('disabled','disabled');          $(this).next().removeattr('disabled');     } else {         $(this).next().attr('disabled','disabled');         $(this).prev().removeattr('disabled');      } }); 
Comments
Post a Comment