Javascript form validation by the code inside a separate file
===

    <script type="text/javascript" src="js/js01.js"></script>
    ...
    <form id="frmReg" method="post" onsubmit="valRegs()" action="memb_area/register.php">
Why the function valRegs() (code is placed inside js01.js file) is not executed, except I drag the code inside html file ?  
How can I be sure that valRegs() is allways executed before and not after code inside register.php file ?