Jump to content

Multiple email validation by Filter validate


lilmer

Recommended Posts

Hello good day,

 

I've got a question how to validate multiple email via Ajax.

Here's my code:

$mailList = $_POST['emailList'];



$pieces = explode(",", $mailList);


foreach($pieces as $row){

if(filter_var($row, FILTER_VALIDATE_EMAIL)){

return true;
}else{
echo '<div class="alert alert-danger">Invalid email address</div>';
return False;
}

};

 

What happen is when I put multiple email on a text area and a first email is true then the next is false it still return TRUE. How can I return FALSE if their is an invalid email on a textarea?

 

Thanks for any idea.

I don't know if it is the right way of coding but this help also.

So what I did is:

 

$mailList = $_POST['emailList'];
$pieces = explode(",", $mailList);
foreach($pieces as $row){

   if(filter_var($row, FILTER_VALIDATE_EMAIL)){          

         $correct = TRUE;
    }else{    
          $correct = FALSE;
    }

};
return $correct;

 

 

Thanks to that $100 rate per/hr that I read. It inspired me! LOL ;D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.