文本框中的任何更改都会自动选中该复选框

Any Change in textbox will automatically check the checkbox

您好,我编写了一个网格视图,其中有一个复选框和两个文本框。我的需要是,当我们在文本框中进行任何更改时,例如将文本从 0 修改为 1,复选框应该会自动选中。此代码在 asp.net 中,可以通过 javascript 或 Jquery.

完成

需要代码来执行此操作 activity。

试试这个例子

Html

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

脚本

$('input[type="text"]').keypress(function(){
$('input[type="checkbox"]').attr("checked","checked");
});

Working demo

这将是这个问题的更好答案。我最初是在 Manoj 的帮助下调试的。再次感谢。

HTML

<input type="text" id="selector"/>
<input type="checkbox" id="myCheckbox"/>

剧本

$('#selector').change(function () {
$('#myCheckbox').prop('checked', true); // Checks it
alert($('#selector').val());
});