IsValidEmail Suggestion

7 posts by 3 authors in: Forums > CMS Builder
Last Post: October 23, 2011   (RSS)

Hello,

Just an idea :)

The 'isValidEmail' built in functionality is great.

It'd be even greater if it allowed multiple email addresses.

Currently, an input such as:

email@google.com, emailtwo@google.com

returns as invalid, even though it's essentially valid.

It'd be great if the isValidEmail allowed this ;)

Cheers!

Re: [rjbathgate] IsValidEmail Suggestion

By Jason - August 8, 2011

Hi,

Thanks for your suggestion. We can look into doing this. As a work around, you can break up your list into an array and check them one at a time like this:

<?php
$emailList = "email@google.com, emailtwo@google.com";
$emailsValid = true;

foreach (explode(",", $emailList) as $email) {
$email = trim($email);
if (!isValidEmail($email)) {
$emailsValid = false;
break;
}
}

?>


At the end of this code, you can check $emailsValid to see if all the emails were valid or not.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] IsValidEmail Suggestion

Hey

Yeah I've used a similar workaround but has meant I've had to customise common.php which isn't ideal for upgrades :)

Thanks :)
Rob

Re: [rjbathgate] IsValidEmail Suggestion

By Jason - August 9, 2011

Hi Rob,

You wouldn't have to customize common.php in order to be able to do this, as you can add this code into your pages. Better still, you can write a function for this and store it in a plugin, so you would have access to the function from any of your pages.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] IsValidEmail Suggestion

true, but I was using the inbuilt mailing function :)

all good, thanks

Re: [Dave] IsValidEmail Suggestion

Legendary :)