(function($) { 'use strict'; $(document).ready(function() { function autoHideGravityFormsErrors() { var errorSelectors = [ '#gform_wrapper_241 .gform_submission_error', '#gform_wrapper_241 .validation_error', '#gform_wrapper_241 .gfield_error', '#gform_wrapper_241 .gform_validation_error' ]; errorSelectors.forEach(function(selector) { var $errors = $(selector); if ($errors.length > 0) { $errors.show(); setTimeout(function() { $errors.fadeOut(800, function() { $(this).remove(); }); }, 300000); // 5 minutes } }); } autoHideGravityFormsErrors(); $(document).on('gform_confirmation_loaded', function(event, formId) { if (formId === 241) { autoHideGravityFormsErrors(); } }); }); })(jQuery);