ActionScript Email Validation

Sooner or later you will face with the small quest of validating an email address for your flash application. The following script is a basic script and should not be used for websites that relay heavily on the email address is being requested (shopping carts, credit card transactions and so forth)

Actionscript:
  1. function isValidEmail(e) {
  2. if (e.indexOf("@") != -1 && ( e.indexOf(".")> e.indexOf("@") ) ){
  3. trace("success");
  4. }else{
  5. trace("error");
  6. }
  7. }
  8.  
  9. //Test
  10. isValidEmail("test@test.com");

6 Responses

  1. Mohammed Zainal Says:

    very good one but what if you got an email like me.u@gmail.com ?
    it will return it false ...

    any idea ?

  2. Anonymous Says:

    How about like this ???
    if (e.indexOf("@") != -1 && ( e.lastIndexOf(".") > e.indexOf("@") ) ) {
    trace("success");
    }else{
    trace("error");
    }

  3. Anonymous Says:


    // a minimum a@a.us is require
    if ((emailString.indexOf("@") > 0) &&
    (emailString.lastIndexOf(".") > (emailString.indexOf("@") + 1)) &&
    (emailString.lastIndexOf(".")

  4. Anonymous Says:


    // minimum a@a.us
    if ((e.indexOf("@") > 0) &&
    (e.lastIndexOf(".") > (e.indexOf("@") + 1)) &&
    (e.lastIndexOf(".")

  5. chandramani Says:

    Hello,

    i want email validation with flash action script which i have
    apply here the code :

    validate_btn.onRelease = function() {
    indexOfAt = email.text.indexOf("@");
    lastIndexOfDot = email.text.lastIndexOf(".");
    if (indexOfAt != -1 && lastIndexOfDot != -1) {
    if (lastIndexOfDot

  6. dfm Says:
    CODE:
    1. function is_valid_email(email:String):Boolean {
    2.     var emailRgx:RegExp = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
    3.     ///^[a-zA-Z0-9][-._a-zA-Z0-9]*@([a-zA-Z0-9]*.)+[a-zA-Z]{2,6}$/;
    4.     trace(emailRgx.test(email));
    5.     return emailRgx.test(email);
    6. }
    7. is_valid_email("c@j.co");

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.