Hello all,
I have created a form in which i have a yes or no question for. When the answer is Yes i want the submission button to be hidden. I only want the user to be able to submit the form if the answer to the question is No.
The current Javascript i have is the following.
$(document).ready(function () {
//Run the showHideSubmit function when the form loads
showHideSubmit();
//Run the showHideSubmit function whenever a radio button changes
$('.mustBeNo').change(function(){
showHideSubmit();
});
//Check for all mustBeYes radio buttons to have a value of No,
//Hide the submit button if any of them have a value of Yes
//Show the submit button is they all have a value of No
function showHideSubmit() {
var n = 0;
$('.mustBeNo input[value=No]').each(function() {
if (!$(this).prop('checked')) {
n++;
}
});
if (n == 0) {
$('.Submit').show();
}
else {
$('.Submit').hide();
}
}
});