Part of the EllisLab Network
   
 
valid_email validation
Posted: 06 August 2006 06:46 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  128
Joined  07-20-2006

Any way of seperating this from being required? I only want to validate if something is a valid email address if its entered, i’d add ‘valid_email|required” if I wanted to require it

Profile
 
 
Posted: 06 August 2006 06:48 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  7337
Joined  03-23-2006

From library.php

function valid_email($str)
    
{
        
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
    
}

So an empty string would fail this.  I guess you could either hack the code, or create your own valid_email private function that allows “” to be entered.

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 06 August 2006 06:52 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
RankRank
Total Posts:  128
Joined  07-20-2006

Sweet, might just do a custom validation function in the controller and modify the regex there

Profile
 
 
Posted: 23 May 2007 02:11 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Avatar
Total Posts:  14
Joined  04-08-2007

but how can i validate if “anyname@anydomain” is real.
how can i validate the “anyname” and “anydomain”.

Profile
 
 
Posted: 23 May 2007 05:49 AM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  7337
Joined  03-23-2006

Short answer… you can’t.

Longer answer, there are various whois lookups you can do for the domain, but this reaches pointlessness pretty quickly.

 Signature 

DerekAllard.com - CodeIgniter, ExpressionEngine, and the World of Web Design
BambooInvoice - Open Source, CodeIgniter powered invoicing.

Profile
MSG
 
 
Posted: 23 May 2007 07:01 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
RankRank
Total Posts:  139
Joined  07-31-2006

Their fault if they dont get their own email address right.

I just posted a bit about how I handle emails in another thread, using PHPMailer, any messages that get undeliverable errors result in me de-activating their account.

 Signature 

Andrew Somervell Beer

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120331 Total Logged-in Users: 62
Total Topics: 126459 Total Anonymous Users: 2
Total Replies: 664986 Total Guests: 479
Total Posts: 791445    
Members ( View Memberlist )