OK, maybe not a beaty, maybe not too difficult but still, it took me 30 minutes to put together and wanted to give these 30 minutes as a gift to the forum members.
So, below you find a method to check a dataprovider with one or more email adresses in it...
Have fun with it (and maybe improve it?)
if (emailvalue != null && emailvalue != "")
{
emailvalue = utils.stringReplace(emailvalue,',',';');
var addressCount = utils.stringPatternCount(emailvalue,';');
if (addressCount != 0)
{var addresses = emailvalue.split(";");}
else
{
var addresses = new Array(0);
addresses[0] = emailvalue;
}
var addressMisMaches = "";
for (var i = 0 ; i < addressCount+1; i++)
{
var match = addresses[i].match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/);
if (match == null)
{
if (addressMisMaches > "")
{addressMisMaches = addressMisMaches + ", "}
addressMisMaches = addressMisMaches + "'" + addresses[i] + "'";
}
}
if (addressMisMaches != "")
{
if (utils.stringPatternCount(addressMisMaches,',') == 0)
{plugins.dialogs.showErrorDialog( "Let op...", "The following emailaddress is wrong:\n" + addressMisMaches, "OK");}
else
{plugins.dialogs.showErrorDialog( "Let op...", "The following emailaddresses are wrong:\n" + addressMisMaches, "OK");}
elements.emailAddress.requestFocus();
}
}