Advertisement
CodeDropz

Untitled

Oct 24th, 2024
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. function drag_and_drop_file_validation() {
  2.     ?>
  3.     <script>
  4.     jQuery(document).ready(function($) {
  5.         $('button[type="submit"]', $('form.cart')).on("click", function(e) {
  6.             var $file = $('input.wc-drag-n-drop-file');
  7.             var $total_files = $('input[name^="' + $file.data('name') + '"]').length;
  8.             $('.has-error-msg').remove();
  9.  
  10.             if ($total_files == 0) {
  11.                 $('.codedropz--results').after('<span class="has-error-msg">File upload is required.</span>');
  12.                 return false;
  13.             }
  14.         });
  15.     });
  16.     </script>
  17.     <?php
  18. }
  19. add_action('wp_footer', 'drag_and_drop_file_validation');
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement