User Comments on 'Javascript Email Validation function'
|
Posted by :
Archive Import (Richard Koudry) at 05:00 on Wednesday, September 18, 2002
|
This function is fantastic, but there is one problem:
It accepts an invalid email address, e.g. try@haveago.
is accepted as a valid address. The address should not finish with a dot unless I am mistaken.
| |
Posted by :
Archive Import (Scott Kreischer) at 18:55 on Tuesday, October 22, 2002
|
<script language="javascript"><!--
function verifyEmail(form) {
checkEmail = form.email.value
if ((checkEmail.indexOf('@') < 0) || ((checkEmail.charAt(checkEmail.length-4) != '.') && (checkEmail.charAt(checkEmail.length-3) != '.')))
{alert("You have entered an invalid email address. Please try again.");
form.email.select();
return false;
}
else {
form.method="get";
form.target="_self";
form.action="myscript.cgi";
form.submit();
}
}
//--></script>
| |
|
|
Posted by :
Archive Import (Bikash Biswas) at 02:34 on Saturday, November 30, 2002
|
There are certain points to be noted
1) What about domain names ending with .de , .se ,.in
2)The e-mail address like "bikash" is valid one. Try any unix box.
3)The e-mail address need not always contain "." . Again try any Unix box.
| |
Posted by :
Archive Import (mamtha) at 04:17 on Wednesday, January 15, 2003
|
Scott Kreischer' code works for .in,.de etc
| |
Posted by :
Archive Import (Paul) at 06:29 on Wednesday, February 19, 2003
|
function validate()
{
validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
strEmail = document.form1.email.value;
if (strEmail.search(validRegExp) == -1)
{
alert(" A valid e-mail address is required.\r\Please check you have entered your details correctly.\r\r\ © Paul Holmes 2001-2003");
return false;
}
| |
Posted by :
Archive Import (DinoBrain) at 14:08 on Wednesday, April 23, 2003
|
hi there...
when i enter an e-mail like this: dino@@yahoo.com .it's still accept this e-mail... can u make it better?
| |
Posted by :
Archive Import (Pedro) at 14:11 on Monday, May 19, 2003
|
To validate email format, I've had luck with the following regular expression:
/^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-z]{2,6}$/i;
However, some browsers (Mac IE?) will result in an alert if there is an underscore. Any ideas why?
| |
Posted by :
Archive Import (murali) at 04:34 on Saturday, June 21, 2003
|
THe email validation should check for the postition of @ and the (.) and the last 3 characters after dot.a maximum length of email not just @ and .
| |
Posted by :
Archive Import (William) at 03:48 on Tuesday, August 12, 2003
|
this is the best I found and it works!
function isEmail(string) {
if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return true;
else
return false;
}
For the explanation:
http://tech.irt.org/articles/js049/index.htm
| |
|
|
Posted by :
Archive Import (goddy) at 13:55 on Wednesday, August 27, 2003
|
i need the function of e-mail to be state out for me
| |
Posted by :
sai_cool at 22:39 on Thursday, April 14, 2005
|
Can any body provide me a solution of running a c++ code using Java.Is there any command.
| |
Posted by :
duncanbeevers at 16:32 on Monday, April 10, 2006
|
Same as William's example above, but true and false are returned implicitly.
function isEmail(string) {
return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
}
| |
Posted by :
bestondoa at 09:15 on Thursday, December 07, 2006
|
The beauty of this function is that it is extraordinarly simple.
Although there are some flaws. For example it will return true with the following string: 'asd@.com' or 'asd.asd@.com', which are obviously not valid e-mail addresses.
So i made a little change, keeping it simple anyway:
function isValidEmail(str) {
return (str.lastIndexOf(".") > 2) && (str.indexOf("@") > 0) && (str.lastIndexOf(".") > (str.indexOf("@")+1));
}
Cheers
<Added>
Here is an updated version.
Now it checks if exists more than one '@', like asd@@asd.com
function isValidEmail(str) {
return (str.lastIndexOf(".") > 2) && (str.indexOf("@") > 0) && (str.lastIndexOf(".") > (str.indexOf("@")+1)) && (str.indexOf("@") == str.lastIndexOf("@"));
}
| |
Posted by :
goit at 15:10 on Tuesday, June 26, 2007
|
This is regarding Posted by : bestondoa at 09:15 on Thursday, December 07, 2006
have you done simple unit tests for your function? In my opinion you might not have tested it with some cases.
Definitely it is not a valid function to check email addresses, for instance if the email value is '.@......' then your function assumes it is a valid email.
Do you think this is a valid email address?
Thanks,
| |
Posted by :
goit at 15:21 on Tuesday, June 26, 2007
|
This is regarding the function provided in the article by Jeff Anderson:
For your convineince here is the function:
function isValidEmail(str) {
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
if the input is '#@@@...' then obviously the function reports as this is a valid email, is that?
I wonder why people get into rush to write something that is erroneous.
Thanks,
Goit
| |
Posted by :
bestondoa at 07:33 on Wednesday, October 31, 2007
|
To goit:
See my post above? Did you get the logic?
Well, next time you find an error, try and help the community by submitting a possible solution.
I did that, solved a couple of errors, but obviously there are more as you correctly pointed out.
Nevertheless your post lacks a solution. If everyone did as you, we wouldn't probably be here reading other people's suggestions/solutions.
Thanks,
Bestondoa
| |
Posted by :
The X One Online at 10:24 on Thursday, May 21, 2009
|
7 years since the post and no one answered it ???
what a shame!!!
here's a function I figured out in a couple of minutes:
[quote]
function isEmail(Mail) {
Mail=Mail.toLowerCase();
return (Mail.search(/^([a-z]+)([a-z0-9\-\_\.]{1,100})([a-z0-9]+)\@([a-z0-9]+)([a-z0-9\-\.]*)([a-z0-9]+)\.([a-z]{2,6})$/) != -1);
}
[/quote]
| |
Posted by :
hiren.pankhaniya at 05:59 on Thursday, August 20, 2009
|
Hi,
Last answered one would accept this email h___.....----@hiren12312h----....hiren123123.hiren which is not a valid email address i think. I have designed this email validation regex this accept only the valid email checked by various mail service providers. /^[a-zA-Z]+([_\.-]?[a-zA-Z0-9]+)*@[a-zA-Z0-9]+([\.-]?[a-zA-Z0-9]+)*(\.[a-zA-Z]{2,4})+$/ I am sure this email validation regex would be very useful to you for email validation in your applications. :-)
| |
Posted by :
latest-sms at 12:57 on Wednesday, October 14, 2009
|
nice article
| |