lilmer Posted February 25, 2013 Share Posted February 25, 2013 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. Link to comment https://forums.phpfreaks.com/topic/274914-multiple-email-validation-by-filter-validate/ Share on other sites More sharing options...
lilmer Posted February 25, 2013 Author Share Posted February 25, 2013 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 Link to comment https://forums.phpfreaks.com/topic/274914-multiple-email-validation-by-filter-validate/#findComment-1414800 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.