-1

I would like to have some checkboxes and same number of input type text. But i would like to have active only some text field. Im using jquery validation plugin. I saw at official documentation that should be working some of like: require:"#checkboxid:check" but for me isnt working.

Can anybody help me please?

Live: http://marygate.cz/aaaa/

Thanks

4

2 回答 2

0

有点难以说出您在问什么,但我相信您想要一个仅在选中相关复选框时才处于活动状态的文本框。

HTML:

<input type="checkbox"/><input type="text" disabled/>

jQuery:

$(":checkbox").change(function() {
    $(this).next(":text").prop("disabled", !this.checked);
});

演示:http: //jsfiddle.net/tymeJV/GFzWU/

于 2013-09-18T13:32:05.717 回答
0

您可以使用 is(':checked') + click() jquery 函数来做到这一点

$("#checkbox1").click( function(){`   
   if( $(this).is(':checked') ){
      $("#inputentry1").removeAttr("disabled");
   }else{
      $("#inputentry1").attr("disabled",true);
   }
});
于 2013-09-18T13:33:35.440 回答