Prestashop Smarty email regular expression validation-Collection of common programming errors
I have a form, and when I submit it, I want to make an email validation before. I created a js file, put in theme’s js directory, included it on the page and my page is WHITE. I activated the errors and I saw that this is the error:
SmartyCompilerException: Syntax Error in template “D:\Projects\mpm_shop\themes\pmart\js\processContactFormEmail.js” on line 44 “var re = /^([a-zA-Z0-9_.-+])+\@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;” – Unexpected “,”, expected one of: “}” , ” ” , ATTR in D:\Projects\mpm_shop\tools\smarty\sysplugins\smarty_internal_templatecompilerbase.php on line 667
My regex is this one:
var re = /^([a-zA-Z0-9_.-+])+\@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
and I try to match it like this:
if (!email.match(re)) {
$('#email').css('border', '1px solid red');
$('.errorEmail').html('Email non è valido');
valid = false;
}
Please help.