A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: email validation

  1. #1
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244

    email validation

    Someone ask me if we could validate an email before submiting to the server script on an 3dfa form.... So here we go

    PHP Code:
    errormsg=""//clear the error message if there is one
    dot=email.indexOf(".",0)//find the dot

    if (dot<1){//No dot?
        
    errormsg+="No dot\n"
        
    }
        else{
    //there is a dot but must have at least two chars after it
            
    ext=email.substr(dot+1)
            if (
    ext.length<|| ext.length>3){
                
    errormsg+="Invalid Domain\n"
                
    }
        }
        
    theat=email.indexOf("@",0)//find the at
    if (theat<0){//no at?
     
    errormsg+="No @ \n"
    }
    else{
    //found at but is there at least one character in front of it?
        
    name=email.substr(0,theat)
            if (
    name.length<1){
                
    errormsg+="must have name\n"
                
    }
        }


    trace (errormsg

    Example
    Source file

  2. #2
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702
    Bret, damn you!

    I was going to help...you beat me to it again.

    Good work.
    I guess that's why they referred to you...(You know who I'm talking about.)

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Location
    Tinley Park, IL
    Posts
    702

    Re: email validation

    Originally posted by blanius
    Someone ask me if we could validate an email before submiting to the server script on an 3dfa form.... So here we go

    PHP Code:
    errormsg=""//clear the error message if there is one
    dot=email.indexOf(".",0)//find the dot

    if (dot<1){//No dot?
        
    errormsg+="No dot\n"
        
    }
        else{
    //there is a dot but must have at least two chars after it
            
    ext=email.substr(dot+1)
            if (
    ext.length<|| ext.length>3){
                
    errormsg+="Invalid Domain\n"
                
    }
        }
        
    theat=email.indexOf("@",0)//find the at
    if (theat<0){//no at?
     
    errormsg+="No @ \n"
    }
    else{
    //found at but is there at least one character in front of it?
        
    name=email.substr(0,theat)
            if (
    name.length<1){
                
    errormsg+="must have name\n"
                
    }
        }


    trace (errormsg

    Example
    Source file
    Bret,
    email is the variable assigned to that edit box right?

  4. #4
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    yes email is the variable in the editbox...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center