uhh, attachments are not allowed here?
class Validate { // characters allowed in e-mail addresses, not including the separators (@ and .) public static var EMAIL_CHARS: String = "abcdefghijklmnopqrstuvwxyz_-"; // test a string for containing allowed characters only public static function containsOnly(aStr: String, aChars: String): Boolean { for (var i = 0; i < aStr.length && aChars.indexOf(aStr.charAt(i)) != -1; i++); return i >= aStr.length } // validate an e-mail address public static function email(aEmail: String): Boolean { var result: Boolean = false; aEmail = aEmail.toLowerCase(); // split into parts at @ characters var a: Array = aEmail.split("@"); // only a single @ is allowed if (result = (a.length == 2)) { // first take the string after the @ character var a2: Array = a[1].split("."); // it should contain at least one dot if (result = (a2.length >= 2)) { // iterate through parts separated by dots for (var i = 0; i < a2.length && result; i++) // check wheter the current part is not empty (or longer than one character in the case // of the last two which denote the TLD and domain name) and contains valid characters only result = (a2[i].length > (i >= a2.length - 2 ? 1 : 0) && containsOnly(a2[i], EMAIL_CHARS)); } if (result) { // take the string before the @ character - it can contain no dots a2 = a[0].split("."); // iterate through parts separated by dots for (var i = 0; i < a2.length && result; i++) // check wheter the current part is not empty and contains valid characters only result = (a2[i].length > 0 && containsOnly(a2[i], EMAIL_CHARS)); } } return result; } } _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com