# Function inside "if" statement

**URL:** <https://forum.kirupa.com/t/function-inside-if-statement/236715>\
**Category:** Uncategorized\
**Created:** [August 23, 2007, 4:56am UTC](https://forum.kirupa.com/t/function-inside-if-statement/236715 "2007-08-23T04:56:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![boogooloo1](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@boogooloo1](https://forum.kirupa.com/u/boogooloo1)\
**Post date:** [August 23, 2007, 4:56am UTC](https://forum.kirupa.com/t/function-inside-if-statement/236715/1 "2007-08-23T04:56:20Z")

</div>

Hi guys,

I’ve spent ages on this with no joy, so thought I’d ask here. I’m trying to validate an email form, say thanks if it’s cool, and then after a short delay (so they can read the thanks), go to a frame. This is what I’ve got:

```auto
 
on (release) {
if(form.uname_txt.text!="" && form.uemail_txt.text!="[EMAIL="%22%20&&%20form.uemail_txt.text.indexOf(%22@%22,0)%3E0"]" && form.uemail_txt.text.indexOf("@",0)>0[/EMAIL] && form.uemail_txt.text.indexOf(".",0)>0){
 // send variables in form movieclip (the textfields)
 // to email PHP page which will send the mail
 name_txt.text = "name:"
 email_txt.text = "email:"
 ErrorMessage.text = "Thank you!";
 form.loadVariables("email.php", "POST");
  delay=1000;
 function back(){
    _root.gotoAndPlay("back");
    clearInterval(intBack);
 }
intBack=setInterval(back,delay);
}
}

```

Bear in mind that the validation code works fine, and I’ve cut some of it so you don’t have to read it all 😉

Anyway, if I get rid of the “if” statement and just have this:

```auto
 
on (release) {

 name_txt.text = "name:"
 email_txt.text = "email:"
 ErrorMessage.text = "Thank you!";
 form.loadVariables("email.php", "POST");
  delay=1000;
 function back(){
    _root.gotoAndPlay("back");
    clearInterval(intBack);
 }
intBack=setInterval(back,delay);
}

```

…it works perfectly, but my validation doesn’t work, obviously. How do I get them both working…?

🙂
