Re: [Flashcoders] as 2 email validation class
Muzak, thank you for the handy google search! Another cool thing you done! Kurt At 04:49 PM 11/19/06, you wrote: http://muzakdeezign.com/flashcoders/?q=email%20validation Muzak ___ 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 ___ 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
Re: [Flashcoders] as 2 email validation class
http://muzakdeezign.com/flashcoders/?q=email%20validation Muzak ___ 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
Re[3]: [Flashcoders] as 2 email validation class
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
Re[2]: [Flashcoders] as 2 email validation class
I have attached a class which - hopefully - takes care of each possible issue :) Attila___ 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
Re: Re[2]: [Flashcoders] as 2 email validation class
there is a problem with the behavior described below: "The above script check for a "@" followed by the last instance of "."..." This turns e-mails from some countries (like [EMAIL PROTECTED]) invalid. For example, I had to fix the e-mail validation in the code of some CMS to develop some sites for brazilians, where we can have e-mails like [EMAIL PROTECTED], [EMAIL PROTECTED] and so on). []'s andrei On 11/19/06, Rákos Attila <[EMAIL PROTECTED]> wrote: This is much better, but not perfect yet :) It still lets pass strings like @., [EMAIL PROTECTED], [EMAIL PROTECTED], foo@@foo.com, etc. I think that validating carefully everything what comes from the user is an essential thing, and we have to don't allow "breaking" programs by wrong inputs. It concerns not only e-mail addresses but any input data. There are two cases when the user passes wrong input to the program: - the user mistyped something or forgot to fill the value at all (unintentionally) - somebody tries to hack the program intentionally We have to take care of both cases, because we should provide the most perfect experience for the user (just take your example: somebody mistypes his/her e-mail address during a registration process and vainly waits for the confirmation mail) and avoid any vulnerability which allows malicious users to hack the program (even when we cannot imagine what harm a wrong input can cause - may be somebody is more inventive and figures out something). JB> Another one I've used is this: JB> -- JB> // vars JB> var checkStr:String = JB> "._-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; JB> var isValid:Boolean; JB> var inputTxt:TextInput; JB> var valBtn:Button; JB> var resultTxt:TextArea; JB> JB> function clicked() { JB> resultTxt.text = (validateEmail(inputTxt.text)) ? "email is valid" : JB> "email is not valid"; JB> } JB> valBtn.addEventListener("click", clicked); JB> JB> function validateEmail(ti:String):Boolean { JB> // ti = text input field string JB> atChrIndex = ti.indexOf("@"); JB> dtChrIndex = ti.lastIndexOf("."); JB> if(atChrIndex < dtChrIndex){ JB> frstStr = ti.slice(0,atChrIndex); JB> mdleStr = ti.slice(atChrIndex+1, dtChrIndex); JB> lastStr = ti.slice(dtChrIndex+1, ti.length); JB> if(getStrValid(frstStr) && getStrValid(mdleStr) && getStrValid(lastStr)){ JB> return true; JB> } else { JB> return false; JB> } JB> } else { JB> return false; JB> } JB> } JB> JB> function getStrValid(ti:String):Boolean { JB> isValid = true; JB> for(var i=0;i if(checkStr.indexOf(ti.charAt(i)) == -1) isValid = false; JB> } JB> return isValid; JB> } JB> -- JB> JB> The above script check for a "@" followed by the last instance of ".", JB> and then splits the email string into three separate strings, and then JB> checks if all the characters in those strings correspond to checkStr. In JB> my script, more than one "." character is allowed in the email, cause JB> I've seen some addresses being something like JB> "[EMAIL PROTECTED]", which isn't allowed in JB> Bokelberg's script. JB> JB> Email validation is fine, to a certain point. Maybe it's just me, but I JB> try and spend the least amount of time on the issue; if a user wants to JB> purposefully try and break the email validation (which they would need JB> to in order to get past a script like the above) then they deserve not JB> to get signed up for whatever. A good signup routine is not just about JB> email validation, but about confirmation: if they purposefully put in an JB> invalid email (which gets past the above routine), then they can't JB> confirm. Sucks to be them. JB> JB> Of course, the simplest thing if you're doing a lot of string validation JB> in your AS2 application is to use a RegExp class. ___ 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 ___ 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
Re[2]: [Flashcoders] as 2 email validation class
This is much better, but not perfect yet :) It still lets pass strings like @., [EMAIL PROTECTED], [EMAIL PROTECTED], foo@@foo.com, etc. I think that validating carefully everything what comes from the user is an essential thing, and we have to don't allow "breaking" programs by wrong inputs. It concerns not only e-mail addresses but any input data. There are two cases when the user passes wrong input to the program: - the user mistyped something or forgot to fill the value at all (unintentionally) - somebody tries to hack the program intentionally We have to take care of both cases, because we should provide the most perfect experience for the user (just take your example: somebody mistypes his/her e-mail address during a registration process and vainly waits for the confirmation mail) and avoid any vulnerability which allows malicious users to hack the program (even when we cannot imagine what harm a wrong input can cause - may be somebody is more inventive and figures out something). JB> Another one I've used is this: JB> -- JB> // vars JB> var checkStr:String = JB> "._-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; JB> var isValid:Boolean; JB> var inputTxt:TextInput; JB> var valBtn:Button; JB> var resultTxt:TextArea; JB> JB> function clicked() { JB> resultTxt.text = (validateEmail(inputTxt.text)) ? "email is valid" : JB> "email is not valid"; JB> } JB> valBtn.addEventListener("click", clicked); JB> JB> function validateEmail(ti:String):Boolean { JB> // ti = text input field string JB> atChrIndex = ti.indexOf("@"); JB> dtChrIndex = ti.lastIndexOf("."); JB> if(atChrIndex < dtChrIndex){ JB> frstStr = ti.slice(0,atChrIndex); JB> mdleStr = ti.slice(atChrIndex+1, dtChrIndex); JB> lastStr = ti.slice(dtChrIndex+1, ti.length); JB> if(getStrValid(frstStr) && getStrValid(mdleStr) && getStrValid(lastStr)){ JB> return true; JB> } else { JB> return false; JB> } JB> } else { JB> return false; JB> } JB> } JB> JB> function getStrValid(ti:String):Boolean { JB> isValid = true; JB> for(var i=0;i if(checkStr.indexOf(ti.charAt(i)) == -1) isValid = false; JB> } JB> return isValid; JB> } JB> -- JB> JB> The above script check for a "@" followed by the last instance of ".", JB> and then splits the email string into three separate strings, and then JB> checks if all the characters in those strings correspond to checkStr. In JB> my script, more than one "." character is allowed in the email, cause JB> I've seen some addresses being something like JB> "[EMAIL PROTECTED]", which isn't allowed in JB> Bokelberg's script. JB> JB> Email validation is fine, to a certain point. Maybe it's just me, but I JB> try and spend the least amount of time on the issue; if a user wants to JB> purposefully try and break the email validation (which they would need JB> to in order to get past a script like the above) then they deserve not JB> to get signed up for whatever. A good signup routine is not just about JB> email validation, but about confirmation: if they purposefully put in an JB> invalid email (which gets past the above routine), then they can't JB> confirm. Sucks to be them. JB> JB> Of course, the simplest thing if you're doing a lot of string validation JB> in your AS2 application is to use a RegExp class. ___ 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
Re: [Flashcoders] as 2 email validation class
Yeah, you're right, that one is a little too simple. Another one I've used is this: -- // vars var checkStr:String = "._-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; var isValid:Boolean; var inputTxt:TextInput; var valBtn:Button; var resultTxt:TextArea; function clicked() { resultTxt.text = (validateEmail(inputTxt.text)) ? "email is valid" : "email is not valid"; } valBtn.addEventListener("click", clicked); function validateEmail(ti:String):Boolean { // ti = text input field string atChrIndex = ti.indexOf("@"); dtChrIndex = ti.lastIndexOf("."); if(atChrIndex < dtChrIndex){ frstStr = ti.slice(0,atChrIndex); mdleStr = ti.slice(atChrIndex+1, dtChrIndex); lastStr = ti.slice(dtChrIndex+1, ti.length); if(getStrValid(frstStr) && getStrValid(mdleStr) && getStrValid(lastStr)){ return true; } else { return false; } } else { return false; } } function getStrValid(ti:String):Boolean { isValid = true; for(var i=0;iThe above script check for a "@" followed by the last instance of ".", and then splits the email string into three separate strings, and then checks if all the characters in those strings correspond to checkStr. In my script, more than one "." character is allowed in the email, cause I've seen some addresses being something like "[EMAIL PROTECTED]", which isn't allowed in Bokelberg's script. Email validation is fine, to a certain point. Maybe it's just me, but I try and spend the least amount of time on the issue; if a user wants to purposefully try and break the email validation (which they would need to in order to get past a script like the above) then they deserve not to get signed up for whatever. A good signup routine is not just about email validation, but about confirmation: if they purposefully put in an invalid email (which gets past the above routine), then they can't confirm. Sucks to be them. Of course, the simplest thing if you're doing a lot of string validation in your AS2 application is to use a RegExp class. __ Joseph Balderson, Flash Platform Developer http://www.joeflash.ca | 416-768-0987 Writing partner, Community MX | http://www.communitymx.com Consultant, New Toronto Group | http://www.newyyz.com Rákos Attila wrote: Well, this is too simple, there are too many invalid strings which are considered as valid by this script. I think if you validate the input, then do it correctly or don't validate at all :) An incomplete validation makes you feel that your data is valid and secure, however it can lead to unexpected problems later. Attila JB> I got a much simpler one: JB> JB> Check for invalidity: JB> JB> // ti = text input field JB> if((ti.text.indexOf("@") == -1) || JB> (ti.text.indexOf(".",(ti.text.indexOf("@")+2)) == -1) ) { JB> // email is invalid JB> } JB> JB> OR... JB> JB> Check for validity: JB> JB> // ti = text input field JB> if((ti.text.indexOf("@") != -1) && JB> (ti.text.indexOf(".",(ti.text.indexOf("@")+2)) != -1) ) { JB> // email is valid JB> } ___ 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 ___ 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
Re[2]: [Flashcoders] as 2 email validation class
Well, this is too simple, there are too many invalid strings which are considered as valid by this script. I think if you validate the input, then do it correctly or don't validate at all :) An incomplete validation makes you feel that your data is valid and secure, however it can lead to unexpected problems later. Attila JB> I got a much simpler one: JB> JB> Check for invalidity: JB> JB> // ti = text input field JB> if((ti.text.indexOf("@") == -1) || JB> (ti.text.indexOf(".",(ti.text.indexOf("@")+2)) == -1) ) { JB> // email is invalid JB> } JB> JB> OR... JB> JB> Check for validity: JB> JB> // ti = text input field JB> if((ti.text.indexOf("@") != -1) && JB> (ti.text.indexOf(".",(ti.text.indexOf("@")+2)) != -1) ) { JB> // email is valid JB> } ___ 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
Re: [Flashcoders] as 2 email validation class
I got a much simpler one: Check for invalidity: // ti = text input field if((ti.text.indexOf("@") == -1) || (ti.text.indexOf(".",(ti.text.indexOf("@")+2)) == -1) ) { // email is invalid } OR... Check for validity: // ti = text input field if((ti.text.indexOf("@") != -1) && (ti.text.indexOf(".",(ti.text.indexOf("@")+2)) != -1) ) { // email is valid } __ Joseph Balderson, Flash Platform Developer http://www.joeflash.ca | 416-768-0987 Writing partner, Community MX | http://www.communitymx.com Consultant, New Toronto Group | http://www.newyyz.com Rich Rodecker wrote: I found this when I was adding stuff to actionscriptclasses.com : http://www.robgonda.com/blog/index.cfm/2006/3/1/actionscript-regular-expression-class the download has an email validation example. On 11/17/06, Steven Sacks | BLITZ <[EMAIL PROTECTED]> wrote: > However it seems to think an email address with less that 4 > characters before the "@' is not valid (when it is). So just modify it to allow less than 4 characters before the @. ___ 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 ___ 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 ___ 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
Re: [Flashcoders] as 2 email validation class
I found this when I was adding stuff to actionscriptclasses.com : http://www.robgonda.com/blog/index.cfm/2006/3/1/actionscript-regular-expression-class the download has an email validation example. On 11/17/06, Steven Sacks | BLITZ <[EMAIL PROTECTED]> wrote: > However it seems to think an email address with less that 4 > characters before the "@' is not valid (when it is). So just modify it to allow less than 4 characters before the @. ___ 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 ___ 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
RE: [Flashcoders] as 2 email validation class
> However it seems to think an email address with less that 4 > characters before the "@' is not valid (when it is). So just modify it to allow less than 4 characters before the @. ___ 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
[Flashcoders] as 2 email validation class
I am looking for an AS@ class that validates a string to see if it is a properly formatted email address. Does anyone have one handy? Or have you seen one around? I found one at : http://www.bokelberg.de/actionscript/checkEmail.html However it seems to think an email address with less that 4 characters before the "@' is not valid (when it is). Thanks in advance! d ___ 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