I would like to show a modal dialogue if a person chooses "No." And it works, but I also need to leave the selected answer "No."
So, after I closed the modal window switch, you did not select. Any ideas how to fix this?
here is my code:
$(function() {
$('#btnNext').attr('disabled', true);
$('input[type="radio"]').change(function(e) {
var $yes = $('input[type="radio"][value="Yes"]');
var $no = $('input[type="radio"][value="No"]');
if ($yes.filter(':checked').length === $yes.length) {
$('#btnNext').attr('disabled', false);
} else {
$('#btnNext').attr('disabled', true);
var $nope = $(this).attr("name");
var $value = $(this).attr("value");
if ($value === "No") {
$(this).attr("checked", "checked");
$('#' + $nope).dialog('open');
}
}
});
});
source
share