I am new to javaScript and the problem I am facing is that I have to match the @ symbol and make sure it is allowed only once in a string. To do so I have written the following regex.
var regexpat=/[@]{1}/;
if(regexpat.test(valu))
testresults = true;
else
{
alert("Please input a valid email address!");
testresults = false;
}
My regex is working for the following input value: abcd@abc@abc.com. However, if I provide the input value as "abcd@"@abc.com it is not throwing the alert error message.
How can I change my regex so that it will work for "abcd@"@abc.com?