prashantcs053
7/3/2017 - 1:04 PM

prevent user to submit , must accept terms and condition checkbox to submit

prevent user to submit , must accept terms and condition checkbox to submit

jQuery(document).bind('gform_post_render', function (event, formId, current_page) {
  var $form = jQuery("form#gform_" + formId);
        if (formId == 2 && current_page == 3) {

            if ($form.length > 0) {
                $form.submit(function () {
                    var terms_condition = false;

                    var $terms_val = jQuery('.terms_condition input[type=radio]:checked').val();
                    if ($terms_val == 'Yes') {
                        terms_condition = true;
                    }
                    if (terms_condition == false) {
                        var $test = jQuery('.terms_condition').find('.accept_message');
                        if ($test.length == 0) {
                            jQuery('.terms_condition').append("<span class='accept_message'>You must accept the terms and conditions to continue.</span>");
                        }
                        window["gf_submitting_" + formId] = false;
//                        jQuery('#gform_ajax_spinner_' + formId).remove();
                        jQuery('.gform_wrapper .gform_ajax_spinner').remove();
                        return false;
                    }
                });
            }
        }
           });