PDA

View Full Version : Email Validation


bugzybee
08-03-2005, 05:07 PM
hi,
I need to validate email address being entered on my form , using javascript.
RIght now I am using the following function,
works fine on IE, but when i tried it in Netscape 6.01.
I faced a problem.

It considers the email ids of the following type to be invaid.
name@something.co.in

I am not sure if something is wrong on the regex being used.

Any input is welcome

function isEmailAddress()
{
var re1 = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var re2 = /^\w|(')+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})$/;
var result = re1.test(this) && re2.test(this);
return result;
}