i'm trying to check if all the fields in my form, which is needed (isRequired=true) are fulfilled. i'm doing it by comparing the form structure (assesmentForm) with the user response (which is on the $scope). i wan't to know some details (starting with VF) about the field and i want it to stop once it found a field which is not fulfilled. the problem is when i'm using the "return" inside the forEach loop - instead of getting out of the forEach it goes to the next iteration (the next function). i tried using: break, continue, labeling, etc' i really need some help
function checkFieldsValidation () {
var VFflag =true; //Validation Failed Flag - true: not failed, False - failed
assessmentForm.Objectives.forEach(function(o){
if (VFflag){
o.component.Fields.forEach(function(f){
if (VFflag){
if (f.IsRequired ){
for (var i in $scope.responses )
{
if( $scope.responses[i].objectives[o.relationship.ActivityRelationshipID][f.FieldID].value.length>0){
VFflag=VFflag;
}
else
{
var VFparIndex=i;
var VFActivityRelationshipID=o.relationship.ActivityRelationshipID;
var VFFieldID = f.FieldID;
VFflag=false;
return;
}
}
}
}
else {return;}
}
)
} else {return;}
}
)
return [VFflag,VFparIndex,VFActivityRelationshipID,VFFieldID];
}