DelphiFAQ Home Search:



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

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Handy function if an email field was filled out properly

Question:

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

Answer:

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:04:01 on Jun 25, 2016