ARTICLE AD BOX
so I have an HTML page, a linked Javascript(jQuery actually) file that has functions linked to clicks, etc. Then I want to add Regular Expressions to check user input. I want to maintain all JS Regular Expressions in one separate file, so that it is easy to manage, in case I add new Regular Exspressions. I tried using Import/Export, but I am getting errors like: Uncaught SyntaxError: Unexpected token 'export' (at 99_JS_Regex.js:1:1) Uncaught SyntaxError: Cannot use import statement outside a module (at 01_JScript_Main.js:3:7)
Here are the files:
<!doctype=HTML> <HTML lang="en"> <HEAD> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta charset="utf-8"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="01_JScript_Main.js"></script> <script type="module" src="99_JS_regex.js"></script> </HEAD> <BODY class="Mainpage"> <DIV> <input class="Inp" name="email" id="email" required placeholder="Email"></input> <button class="TML_Btn" id="Login_Button">Submit</button> </DIV> </BODY> </HTML>File 99_JS_Regex:
export JS_Email_RG = "/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/";File 01_JScript_Main.js:
(document).ready(function(){ $("#Login_Button").click(function(){ import JS_Email_RG from './99_JS_regex.js'; alert JS_EM_RG; }); });Also, I am not sure how to specify the path to the module file.. is it './module_file.js' or should I simply put 'module_file.js' or "'module_file.js'". many thanks...
