I'm running a PHP code to validate login form and if there's an input empty it should run a javscript function that changes the display attribute of some DIVs to block. If I put my JS code between the head tag it says
Uncaught TypeError: Cannot read property 'style' of null
, and If I put my code before the /body tag it says
Uncaught ReferenceError: formValidation is not defined
Javascript code:
function formValidation() {
     document.getElementById("errMessage").style.display = "block",
    document.getElementById("arrow-errMessage").style.display = "block",
    document.getElementById("errEmail").style.display = "block",
    document.getElementById("arrow-errEmail").style.display = "block"; 
} 
PHP code:
else {
          echo "<script> formValidation(); </script>";
    }
 
     
     
    