Submit
Path:
~
/
home
/
getwphos
/
www
/
shellfish
/
wp-content
/
plugins
/
dealership
/
assets
/
js
/
File Content:
validation.js
(function($){ $.fn.exists = function(){ return this.length > 0; } function dealership_validation(div) { var status = false; // var var ignore = false, $tab = null; // set validation data div.data('validation', true); // not visible if( div.is(':hidden') ) { // ignore validation ignore = true; // if this field is hidden by a tab group, allow validation if( div.hasClass('acf-tab_group-hide') ) { ignore = false; // vars var $tab_field = div.prevAll('.field_type-tab:first'), $tab_group = div.prevAll('.acf-tab-wrap:first'); // if the tab itself is hidden, bypass validation if( $tab_field.hasClass('acf-conditional_logic-hide') ) { ignore = true; } else { // activate this tab as it holds hidden required field! $tab = $tab_group.find('.acf-tab-button[data-key="' + $tab_field.attr('data-field_key') + '"]'); } } } // if is hidden by conditional logic, ignore if( div.hasClass('acf-conditional_logic-hide') ) { ignore = true; } // if field group is hidden, igrnoe if( div.closest('.postbox.acf-hidden').length ) { ignore = true; } if( ignore ) { return; } // text / textarea if( div.find('input[type="text"], input[type="email"], input[type="number"], input[type="hidden"], textarea').val() == "" ) { div.data('validation', false); } // wysiwyg if( div.find('.acf_wysiwyg').exists() && typeof(tinyMCE) == "object") { div.data('validation', true); var id = div.find('.wp-editor-area').attr('id'), editor = tinyMCE.get( id ); if( editor && !editor.getContent() ) { div.data('validation', false); } } // select if( div.find('select').exists() ) { div.data('validation', true); if( div.find('select').val() == "null" || ! div.find('select').val() ) { div.data('validation', false); } } // radio if( div.find('input[type="radio"]').exists() ) { div.data('validation', false); if( div.find('input[type="radio"]:checked').exists() ) { div.data('validation', true); } } // checkbox if( div.find('input[type="checkbox"]').exists() ) { div.data('validation', false); if( div.find('input[type="checkbox"]:checked').exists() ) { div.data('validation', true); } } // relationship if( div.find('.acf_relationship').exists() ) { div.data('validation', false); if( div.find('.acf_relationship .relationship_right input').exists() ) { div.data('validation', true); } } // repeater if( div.find('.repeater').exists() ) { div.data('validation', false); if( div.find('.repeater tr.row').exists() ) { div.data('validation', true); } } // gallery if( div.find('.acf-gallery').exists() ) { div.data('validation', false); if( div.find('.acf-gallery .thumbnail').exists()) { div.data('validation', true); } } // hook for custom validation $(document).trigger('acf/validate_field', [ div ] ); // set validation if( ! div.data('validation') ) { // show error this.status = false; div.closest('.field').addClass('error'); // custom validation message if( div.data('validation_message') ) { var $label = div.find('p.label:first'), $message = null; // remove old message $label.children('.acf-error-message').remove(); $label.append( '<span class="acf-error-message"><i class="bit"></i>' + div.data('validation_message') + '</span>' ); } // display field (curently hidden due to another tab being active) if( $tab ) { $tab.trigger('click'); } } } // $(document).on('submit', '#dealership_register', function() { // // // // If disabled, bail early on the validation check // // if (acf.validation.disabled) { // // return true; // // } // alert("Validation"); // // // loop through all fields // $('.field.required, .form-field.required').each(function () { // // // run validation // _this.validate($(this)); // // // }); // }); $(document).ready(function(){ console.log($("#dealership_register")); $(document).on('submit', '#dealership_register', function() { // // If disabled, bail early on the validation check // if (acf.validation.disabled) { // return true; // } // alert("Validation"); // console.log($(this)); // loop through all fields $(this).find('.field.required, .form-field.required').each(function () { // run validation var __validate = dealership_validation($(this)); console.log(__validate); }); return false; }); }); // $(document).on('submit', '#dealership_register', function() { // // // // If disabled, bail early on the validation check // // if (acf.validation.disabled) { // // return true; // // } // // alert("Validation"); // // console.log($(this)); // // console.log($(this).find('.field.required, .form-field.required')); // // // loop through all fields // $(this).find('.field.required, .form-field.required').each(function () { // // // run validation // var __validate = dealership_validation($(this)); // console.log(__validate); // // // // }); // return false; // }); })(jQuery);
Submit
FILE
FOLDER
Name
Size
Permission
Action
dealership.js
9046 bytes
0644
validation.js
7595 bytes
0644
N4ST4R_ID | Naxtarrr