Sha256: a0f1e66265867ad042319858fbf169df8c5a550c3c7055e837bb2b7e1c07e25b

Contents?: true

Size: 1.2 KB

Versions: 16

Compression:

Stored size: 1.2 KB

Contents

$(document).on('click', '.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('.select2').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 $('.form_submit').button('loading');
  }
});

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
cm-admin-1.4.9 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.4.8 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.4.7 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.4.6 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.4.5 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.4.4 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.4.3 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.4.2 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.4.1 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.4.0 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.3.9 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.3.8 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.3.7 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.3.6 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.3.5 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.3.4 app/assets/javascripts/cm_admin/form_validation.js