Basically I am trying to have a text box that upon change it checks if a valid email is in place and if so the form is submitted for the user. I would like to improve the regex too to only allow a specific domain but I can't get any regex to work due to every time I use a @ sign it thinks I am trying to use C# code I looked it up and supposedly adding a : fixes it but it hasn't for me and I tried a ; too.
document.getElementById("txtCallerID").onchange = function () {
var temp = document.getElementById("txtCallerID").value
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(temp))
{
this.document.submit();
}
}
and here is a picture with the error.
Have now also tried adding a backslash before the @ to no avail.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/JZcIChS
Comments
Post a Comment