« [tip] 'Try' your statements and 'Catch' an exception | Main | [News] Servoy World 2005 photos »
October 21, 2005
[Tip] Validate email addresses
by Harjo Kompagnie
Direct ICT
Use this method to check for the validity of email addresses:
var x = 'harjo@directict.nl'
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(x))
{
var b = 'YES! Correct email address'
}
else
{
var b = 'NO! Incorrect email address';
}
| Posted by David Workman on October 21, 2005 at 09:27 PM in Tips | Permalink
Comments
Great tip Harjo!
And just at the moment I was ready to implement such a check.
Thanks!
Posted by: Robert J.C. Ivens | Oct 22, 2005 4:33:00 AM
Hello Harjo,
Nice tip but can you please explain what you are doing here? I don't understand this at all...
Thank you,
Henry
Posted by: Henry Buckweet | Oct 22, 2005 2:12:29 PM
He's using a regular expression to validate two things about the email address string: the format and allowed characters. This is standard JavaScript and you can find tons of information on it by googling "email validation with javascript".
Posted by: David Workman | Oct 22, 2005 3:40:01 PM