Say for example I have the following:
<input type="checkbox" id="chk-box1" name="chk-box1" value="Check 1">Check 1
<input type="text" id="textbox1" name="textbox1" value="">
I can set the value of the textbox when “chk-box1” is clicked by doing:
$('#chk-box1').change(function(){
var chk = $(this);
$('#textbox1').val("Textbox 1 is checked")('selected', chk.attr('checked'));
})
but how could I set the value of the textbox to empty when the box is unchecked? $('#textbox1').val("")
Try this,
Live Demo
if you want to show message instead of true or false.