For an application I'm working on, I'm trying to create three eligibility question on three separate pages before one can reach the main application. The first page contains this javascript and works well - it hides the Next button until a valid entry is input into the pcn field:
$(document).ready(function(){
$(".pcn input").change(validate);
validate();
$('.cf-next-btn').click(validate);
function validate() {
if ($(".pcn input").parsley({excluded:":hidden"}).isValid()) {
$('.cf-next-btn').show();
}
else {
$('.cf-next-btn').hide();
}
}
});
For each of the next two pages/questions, I would like the Next button to be hidden by default and only show if the answer to a radio button question is Yes. The only difference between the two pages is the CSS class. I tried the code below, but the Next button does not hide by default, and only hides when the No answer is selected.
$(document).ready(function(){
$('.cf-next-btn').hide();
$('.affected input').change(function(){
if($('.affected input[value="Yes"]:checked').length > 0){
$('.cf-next-btn').show();
}
else{
$('.cf-next-btn').hide();
alert ('Show alert.');
}
});
});
I'm wondering if there is some confusion going on with so many show/hide commands, and if it's possible to distinguish the show/hides by the ID for the page...?
Thank you in advance for any assistance.