document.addEventListener('DOMContentLoaded', function () { checkErrors(); }, false); function checkErrors() { if (isFormSubmitted()) { showErrors(); } } function isFormSubmitted() { return window.location.href[window.location.href.length - 1] == "#"; } function showErrors() { x = document.getElementsByClassName('error'); for (let i = 0; i < x.length; i++) { x[i].style.display = 'block'; } }