required form input.

I have a e-mail form in my flash that is sent when the send button is pressed. How do I require a value in phone and email text fields before the email can be sent?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

do you mean you want to check if the fields are not empty.

then simply

if ((phoneField.text != ") && (emailField.text != "")) {
do whatever
} else {
alert message

where phoneField and emailField are the instance names not variables of your input text fields, and alert message is as it says.
The first thing you would need to do is set the variable name or instance name to something like "phone_txt".
In your actionscript to require a value, you could use this code:

on (release){
      if (_root.phone_txt.length < 8) {                                     // If less than 8 digits is entered in the text box, the message below will apear
            _root.message = "The phone number you have entered is not valid"
      } else {
            // Add your code in here

If you have any problems, questions or comments feel free to let me know.


Here is a better way to do what your trying to achieve:

on (release) {
     if (!this._parent.phonenumber.length) {
          this._parent.status = "Please enter a phone number";
     } else {
          if (! ||
     "@") == -1 ||
     ".") == -1 ||
     "com") == -1) {
               this._parent.status = "Please enter a valid email";
          } else {
               if ( < 7) {
                    this._parent.status = "Please enter a valid email";
               } else {
                 // Rest of your code goes here
apwbeAuthor Commented:
Sorry for taking so long getting back on this. Been kinda rushed. I tried the solutions above and probably did not get the code right as I could not get them to work.

My flash form passes the values to an .asp that handles sending the email maybe I should put the checks in the .asp instead of the flash mov.. Anyway here is the code for sending the values to the .asp.

on (Release) {
_parent.getURL("mail_form.asp", "_new", "POST");      

Here is the code in the .asp


Body = "Name: "& request("name") & vbcrlf
Body = Body & "From: "& request("from") & vbcrlf
Body = Body & "Phone: "& request("phone") & vbcrlf
Body = Body & "Destination: "& request("destination") & vbcrlf
Body = Body & "Arrive: "& request("arrive") & vbcrlf
Body = Body & "Depart: "& request("depart") & vbcrlf
Body = Body & "Message: "& vbcrlf & request("comments")

Set Mail = Server.CreateObject("Persits.MailSender")
            ' enter valid SMTP host
            Mail.Host = "localhost"

            Mail.From = request("from")  ' From address
            Mail.AddAddress ""            
            ' message subject
            Mail.Subject = "Reservation/Info Request"
            ' message body
            Mail.Body = Body

            strErr = ""
            bSuccess = False
            On Error Resume Next ' catch errors
            Mail.Send      ' send message
            If Err <> 0 Then ' error occurred
                  strErr = Err.Description
                  bSuccess = True
            End If


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">


<body bgcolor="#FFFFFF" text="#000066" link="#0000CC" vlink="#0000CC" alink="#0000CC">

<script languages="javascript">

<div align="center">
<p><font face="Verdana" size="2" color="#000080"> <font face="Arial, Helvetica, sans-serif" size="4"><b>Thank you,<br><br>Your reservation/info request has been sent. We will be in contact soon.<br><br>Warren Elkins<br>Mexico-Bound</b></font></font></p>
<p><b><font face="Arial, Helvetica, sans-serif" size="4" color="#000080">To
Return To Flash Page</font></b></p>
<p><b><font face="Arial, Helvetica, sans-serif" size="4" color="#000080"><a href="fz_jt020.html">Click
Here</a> </font></b> </p>

Here is a link to the site. Look under reservations.
on (release) {
                 myEmail = new LoadVars();
        = name;               // name should be the variable name of your input boxes. And the same for all the other input boxes
                 myEmail.from = from;
        = phone;
                 myEmail.destination = destination;
                 myEmail.arrive = arrive;
                 myEmail.depart = depart;
                 myEmail.comments = comments;
                 myEmail.sendAndLoad("mail_form.asp", myEmail, "POST");
                 myEmail.onLoad = function(success)
                      if (success)
                           //Add success message or gotoAndStop which ever frame you want it to go
                           //Add your error message here

This should send all the variables to your asp page.
If you need anymore help, give me a yell.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.