Sha256: 6b209fe4714358920f5bfdbb135f3c544856bcdc2b7d0275c42d90a17c3c088c

Contents?: true

Size: 1.24 KB

Versions: 23

Compression:

Stored size: 1.24 KB

Contents

$(document).on('click', '[data-behaviour="form_submit"]', function (e) {
  e.preventDefault();
  var submit = [];
  var form_class = $(this).data('form-class');
  $("." + form_class + " input.required, ." + form_class + " textarea.required").each(function () {
    $(this).removeClass('is-invalid');
    if ($(this).val().trim().length === 0) {
      $(this).addClass('is-invalid');
      $(this)[0].scrollIntoView(true);
      submit.push(true);
    }
  });
  $("." + form_class + " select.required").each(function () {
    $(this).removeClass('is-invalid');
    if ($(this).val().trim().length === 0) {
      $(this).parent().find('select').addClass('is-invalid');
      $(this)[0].scrollIntoView(true);
      submit.push(true);
    }
  });
  $('.nested_input_validation').each(function () {
    var class_name;
    class_name = $(this).data('class-name');
    $(this).parents(':nth(1)').find('.' + class_name).addClass('hidden');
    if ($(this).val().trim().length === 0) {
      $(this).parents(':nth(1)').find('.' + class_name).removeClass('hidden');
      $(this)[0].scrollIntoView(true);
      submit.push(true);
    }
  });
  if (submit.length === 0) {
    $('.' + form_class).submit();
    return $('[data-behaviour="form_submit"]').button('loading');
  }
});

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
cm-admin-1.5.37 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.36 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.35 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.34 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.33 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.32 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.31 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.30 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.29 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.28 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.10 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.27 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.26 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.25 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.23 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.22 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.21 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.20 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.11 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.5.9 app/assets/javascripts/cm_admin/form_validation.js