Hi,
I have a large group of radio button questions within a tab container in a form, I want to ensure all have an answer on save at a specific stage. I can't simply make them mandatory fields because it's a large form filled in at different stages, so they are not mandatory at the first stage.
Therefore I have attached a validation function to one field and written some code to validate all radio button questions within the tab container if at the specific stage, instead of having to use a different validation function for each one:
fd.field('Section_x0020_B').validators.push({
name: 'Technical radio buttons validation',
error: 'Please select a response to all multi-value questions in Section B' ,
validate: function(value) {
if(fd.field('Stage').value == 'Technical Information/Confirmation') {
$(".tab-content .fd-radio-group").each(function(){
if($(this).find("input:radio:checked").length > 0) {
// Response has a value
console.log("OK CONTINUE")
}
else {
console.log("FALSE, STOP!!!")
return false
}
});
}
return true
}
});
I then have a custom save function, in which the first line is to log the fd.isValid value before using it in an if block to continue:
window.SaveForm = function() {
console.log(fd.isValid);
if(fd.isValid) {...
In the console I can see the first line logged on save of the form is "FALSE, STOP!!!" showing it has hit the return false statement in the validation function, however then the next line logged is true, showing that fd.isValid is returning true where it should return false? Why is this the case?
Thanks