DelphiFAQ Home Search:

InterBase, MS-SQL, mysql, Oracle
C#, C++, Delphi, Java,
JavaScript, perl, php, Visual Basic, VBScript
Apache, Network, Shell
Web Publishing
JavaScript, perl CGI, VBScript, Web Hosting
Apache, File Types, Internet Explorer,
Network, Printing, Processes
Outside the Cube
Auto, Computer Hardware,
Finances, Dating Scams,
Household, Male Dating Scammers,
Other Scams, Travel

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 0:02:18 on Aug 13, 2020