user2457688
user2457688

Reputation: 31

Any Change in textbox will automatically check the checkbox

Hi I have coded a Grid view where we have one checkbox and two textbox. My need is that as we make any change in textbox like modify text from 0 to 1, the Checkbox should get automatically checked. This code is in asp.net and this can be done by javascript or Jquery.

Need code to do this activity.

Upvotes: 1

Views: 903

Answers (2)

user2457688
user2457688

Reputation: 31

This will be Better answer of this question.. I initially debug by help of Manoj. Thanks again.

HTML

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

SCRIPT

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

Upvotes: 1

Manoj
Manoj

Reputation: 5071

Try this example

Html

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

Script

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

Working demo

Upvotes: 2

Related Questions