DelphiFAQ Home Search:
General :: Web publishing
Information about web publishing, how to maintain, optimize and promote a web site.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

Handy function if an email field was filled out properly


I need to check whether a user filled out the email field with a valid email address. Any ideas?


The only way to prove it is valid is to send a confirmation email with some secret url and or code to that email address, have the user read the email and click on the URL that comes in it. That way you verify that the user provided an email that actually exists.

Sometimes you can rely on the user's strong interest to provide a valid email address or you simply do not want to wait until the user has completed this process.

And even if you send the confirmation email, it does not hurt to do a syntactical check. The following code checks if there is an @ and a dot in the email address.

Note that theoretically an email does not necessarily contain the @ sign - e.g. it could be coded as %64 (which corresponds to the @ symbol).

function isEmail(str) 	{
 if ((str == null) || 
             (str.length == 0) || 
             (str.indexOf("@")) == -1 || 
             (str.indexOf(".")) == -1) 
   return false; 
 else { 
   return true; 

Generated 12:02:00 on Oct 26, 2020