Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit button not working in flash guestbook...

Status
Not open for further replies.

beeej21

Technical User
Jul 7, 2003
67
0
0
US
Hey all,
I have created a very simple flash guestbook. It actually works, however, I am trying to make it such that if the user DOES NOT input a name, email address, and a comment, then an error message pops up. This the actionscript attached to my submit button. ActionScript 2.0 btw.

Code:
on (release)
{
    if (name == null)
    {
        this.error.gotoAndPlay(2);
        this.error.error_message = "You should enter your name!";
    }
    else if (email == null)
    {
        this.error.gotoAndPlay(2);
        this.error.error_message = "You should enter your email address!";
    }
    else if (email.indexOf("@", 0) < 0)
    {
        this.error.gotoAndPlay(2);
        this.error.error_message = "Your email address is invalid!";
    }
    else if (email.indexOf(".", 0) < 0)
    {
        this.error.gotoAndPlay(2);
        this.error.error_message = "Your email address is invalid!";
    }
    else if (comment == null)
    {
        this.error.gotoAndPlay(2);
        this.error.error_message = "You should leave a comment!";
    }
    else
    {
        submit = "yes";
        low_num = 0;
        high_num = 10;
        this.entries = "<b>Thank you " + name + " for your comments!</b><br>Retrieving new entry...";
        loadVariablesNum("dguestbook.php", 0, "POST");
        this.gotoAndPlay(22);
    } // end else if
}

So when testing this, I DO get a message saying "Your email address is invalid" if there is nothing inputed anywhere. However, it should say "You should enter your email address!". In fact, before that, it ought to tell me "You should enter your name!" Because if I leave all fields blank, that should be the first error.

Somehow, I have a feeling that the

Code:
if (name == null)

code is not working. However, the

Code:
(email.indexOf

IS working.

Is there another ActionScript I can use to replace the code that is == null? Is that my problem? Please help, thank you.
 
Okay... um... I feel stupid. I got everything working okay. It seems that I had spaces in the "name" and "comment" fields. Once I deleted the spaces IN the fields, everything is working okay now. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top