Solved

required form input.

Posted on 2003-11-24
5
231 Views
Last Modified: 2012-05-04
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?
0
Comment
Question by:apwbe
  • 3
5 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 9816375
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.
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9816384
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.

Cheers

-OBCT
0
 
LVL 9

Expert Comment

by:OBCT
ID: 9918609
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 (!this._parent.email.length ||
               this._parent.email.indexOf("@") == -1 ||
               this._parent.email.indexOf(".") == -1 ||
               this._parent.email.indexOf("com") == -1) {
               this._parent.status = "Please enter a valid email";
          } else {
               if (this._parent.email.length < 7) {
                    this._parent.status = "Please enter a valid email";
               } else {
                 // Rest of your code goes here
               }
          }
     }
};
0
 

Author Comment

by:apwbe
ID: 9962027
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 "elkins@gci.net"            
            ' 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
            else
                  bSuccess = True
                                               
            End If


%>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>mail</title>
<head>



</head>


<!--THIS BIT SAYS THANKS AND HAS A MANUAL LINK BACK TO basic_mail.htm-->
<body bgcolor="#FFFFFF" text="#000066" link="#0000CC" vlink="#0000CC" alink="#0000CC">

<script languages="javascript">
window.resizeTo(500,500);
</script>


<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>
</div>
</body>
</html>

Here is a link to the site. Look under reservations.

http://www.mexico-bound.com
0
 
LVL 9

Accepted Solution

by:
OBCT earned 200 total points
ID: 9962122
on (release) {
                 myEmail = new LoadVars();
                 myEmail.name = name;               // name should be the variable name of your input boxes. And the same for all the other input boxes
                 myEmail.from = from;
                 myEmail.phone = 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
                      }
                      else
                      {
                           //Add your error message here
                      }
                  }
};

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

Cheers

-OBCT
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SCCM 2012 - Deploy Flash 16 6,900
Flash player plugin 13 7 324
Google Chrome Blank White Screens 13 293
Flash Slides/Presnetation 4 71
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now