I’m trying to detect when a checkbox is un-checked and if the corresponding field below (with an Id) has a value, then empty it.
Any ideas?
I’m working with the following but it isn’t working:
$('#end_date_specified').click(function() {
$('#end_date_datepicker, #end_date_datepicker_altfield').empty();
$('#datediv').toggle();
});
I think one of the problems with this is that it will empty the field values no matter how the checkbox is clicked.
I think this is what you want:
Only on
change(better thanclickedto get the right state) we only clear if it’s not.checked, then we show the#datedivbased on whether it’s checked (show if it is, hide if it isn’t) using.toggle(bool).