# Problem with validation: newsletter subscription email field

**URL:** <https://forum.kirupa.com/t/problem-with-validation-newsletter-subscription-email-field/227151>\
**Category:** Uncategorized\
**Created:** [May 27, 2007, 8:40pm UTC](https://forum.kirupa.com/t/problem-with-validation-newsletter-subscription-email-field/227151 "2007-05-27T20:40:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lunasol](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@Lunasol](https://forum.kirupa.com/u/Lunasol)\
**Post date:** [May 27, 2007, 8:40pm UTC](https://forum.kirupa.com/t/problem-with-validation-newsletter-subscription-email-field/227151/1 "2007-05-27T20:40:57Z")

</div>

Hi,

Ususally when I put in a regular contact form in Flash (you know, name, email and message), I use Senocular’s tutorial and have the validation on Name as req. field and syntax of Email field and it always works great.

Now I have this form consisting of just an Email field and a Submit button. The filled-in address is supposed to be added to an external database from a paid newsletter service. Their requirements are: - a specific var. name for the field and the action url where the submitted info is processed to their clients database so to speak, so I have to open that page in order for the input to be processed (in a new window).

When I put this on the submit button:

```auto
on (release) {
    loadVariablesNum ("http://www.ymlp.com/subscribe.php?clientsname", "_blank", "POST");
    gotoAndStop("thanks");
}

```

it works. But no validation on the filled-in address, so the external page gives an error with anything that’s not an email address.  
(in url: real client’s accountname substituted here for ‘clientsname’)

So I put this on the button:

```auto
on (release) {
    formcheck ();
}

```

And this in an actionframe a layer above (email is the instance name of the field, and its var name is YMLP0):

```auto

action = "send";

function validate (email) {
    if (email.length>=7) {
        if (email.indexOf("@")>0) {
            if ((email.indexOf("@")+2)<email.lastIndexOf(".")) {
                if (email.lastIndexOf(".")<(email.length-2)) {
                    return (true);
                }
            }
        }
    }
    return (false);
}

function formcheck () {
    if ((((email == null)) || (email.length<1)) || (email == "No valid email address")) {
        email = "No valid email address";
        action = "";
    }
    if (!validate (email)) {
        email = "No valid email address";
        action = "";
    }
    if ((validate (email)) && (email != "ERROR!")) {
        action = "send";
        loadVariablesNum ("http://www.ymlp.com/subscribe.php?clientsname", "_blank", "POST");
        gotoAndStop("thanks");
        }
    }

```

But it doesn’t do anything.

Can anyone point me in the right direction? I’m really no scripter, just a designer I’m afraid :cross-eye.

Many thanks.
