Posts: 850
Name: Matt Pealing
Location: England, north west
|
can anyone see whats wrong with this code? its supposed to validate an email address using a regular expression, but even if a valid address is entered it always just brings up the alert box.
Code:
function reg(str)
{
var regEx = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-z]{2,6}$/
if(regEx.test(str))
{
return true;
}
else
{
alert('Please enter a valid email address');
return false;
}
}
|