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)

[as]function isValidEmail(e) {
if (e.indexOf(“@”) != -1 && ( e.indexOf(“.”) > e.indexOf(“@”) ) ){
trace(“success”);
}else{
trace(“error”);
}
}

//Test
isValidEmail(“test@test.com”);
[/as]

← Back to home

7 thoughts on “ActionScript Email Validation

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


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


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

  4. 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

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

Comments are closed.