Common.js: Difference between revisions
From MiniPC.club
Philo3lancer (talk | contribs) No edit summary Tag: Reverted |
Philo3lancer (talk | contribs) No edit summary Tag: Manual revert |
||
Line 28: | Line 28: | ||
alert(errorMessage); | alert(errorMessage); | ||
event.preventDefault(); | 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(); } }); });