Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.