It should stop submitting based on all the conditions below. I am getting error in console as unexpected end of json input now.

 

var obj = JSON.parse(mrvs);
    if ((obj.length == 0) && (domain == 'AD.COM')) {
        g_form.addErrorMessage("No Certifications");
        return false;
    } else if (obj.length < 4 && (domain == 'nonprod.int') || (domain == 'int')) {
        g_form.addErrorMessage("Please complete remaining courses");
        return false;
    } else {
        for (var i = 0; i < obj.length; i++) {
            var startDTe = obj[i].course_completed_date; // name of the MRVS variable
            total = total + parseInt(obj[i]).course_completed_date; // give here the variable name for proportion
            var startDateNum = getDateFromFormat(startDTe, g_user_date_format);
            var coursedate = today - startDateNum;
            //alert(coursedate);
            var dayDifference = coursedate / (1000 * 60 * 60 * 24);
            //alert(dayDifference);
            if (dayDifference > 365) {
                g_form.addErrorMessage("Course Completed Date should not be more than 365 days");
                return false;
            }
        }