Actions

MediaWiki

Common.js: Difference between revisions

From MiniPC.club

No edit summary
No edit summary
Tag: Manual revert
 
(4 intermediate revisions by the same user not shown)
Line 5: Line 5:
     }
     }
});
});
  $(document).ready(function() {
      $('form').submit(function(event) {
          let isValid = true;
          let errorMessage = '';
          // Checking the required fields
          if ($('#Field_Brand').val() === '') {
              isValid = false;
              errorMessage += 'Please fill out the Brand field.\n';
          }
          if ($('#Field_Model').val() === '') {
              isValid = false;
              errorMessage += 'Please fill out the Model field.\n';
          }
          if ($('#Field_CPU_Model').val() === '') {
              isValid = false;
              errorMessage += 'Please fill out the CPU Model field.\n';
          }
          // If it is not valid, we show an error message and prevent the form from being submitted.
          if (!isValid) {
              alert(errorMessage);
              event.preventDefault();
          }
      });
  });

Latest revision as of 21:08, 18 April 2025

/* Any JavaScript here will be loaded for all users on every page load. */
$(document).ready(function() {
    if (mw.config.get('wgPageName') === 'Special:FormEdit') {
        window.location = 'Special:FormEdit/Mini-PC/_';
    }
});
   $(document).ready(function() {
       $('form').submit(function(event) {
           let isValid = true;
           let errorMessage = '';

           // Checking the required fields
           if ($('#Field_Brand').val() === '') {
               isValid = false;
               errorMessage += 'Please fill out the Brand field.\n';
           }
           if ($('#Field_Model').val() === '') {
               isValid = false;
               errorMessage += 'Please fill out the Model field.\n';
           }
           if ($('#Field_CPU_Model').val() === '') {
               isValid = false;
               errorMessage += 'Please fill out the CPU Model field.\n';
           }

           // If it is not valid, we show an error message and prevent the form from being submitted.
           if (!isValid) {
               alert(errorMessage);
               event.preventDefault();
           }
       });
   });