4 Replies Latest reply on Jul 1, 2008 5:14 AM by CipiClaudiu

    Contact Form - mandatory Fields

    CipiClaudiu Level 1
      Hi,

      I am working on a contact form and I need you to help me add script to this so users can only send mail if they fill all the fields
      Below you can see the as lines I'm using
      ----------------------------------------------------------------------
      rec="mail adress comes here";
      serv="php";

      var fields_descriptions= Array ("",
      Array("t1", "your_name", "Your Name:"),
      Array("t1", "your_phone", "Phone:"),
      Array("t2", "your_email", "Your Email:"),
      Array("t3", "subject", "Subject:"),
      Array("t4", "message", "Message:"),
      Array("t5", "field_2", "E-mail:"),
      Array("t6", "field_3", "Address:"),
      Array("t7", "field_4", "fax:")
      );



      for (i=1; i<=fields_descriptions.length; i++) {
      this["k"+i].text=fields_descriptions [2];
      }
      ------------------------------------------------------------------------------------
        • 1. Contact Form - mandatory Fields
          jon gibbons
          This works

          You will have to drag an "Alert Component onto the stage:

          import mx.controls.*;
          // when the submit button is clicked, send the form values to the server using a LoadVars object.
          var postBtnListener:Object = new Object();
          postBtnListener.click = function(evt:Object) {
          // if the name is blank, display an error message using the Alert component.
          if (your_name.text.length == 0) {
          Selection.setFocus(your_name);
          Alert.show("Please enter your Your Name.", "Error", Alert.OK);
          return false;
          }
          if (your_phone.text.length == 0) {
          Selection.setFocus(your_phone);
          Alert.show("Please enter your Phone Number.", "Error", Alert.OK);
          return false;
          }
          if (your_email.text.length == 0) {
          Selection.setFocus(your_email);
          Alert.show("Please enter your E Mail Address.", "Error", Alert.OK);
          return false;
          }
          and so on:

          send_lv.onLoad = function(success:Boolean) {

          // if the comments were sent to the server and you received a response, clear the form fields and display an Alert message.
          if (success) {
          your_name.text = "";
          your_phone.text = "";
          your_email.text = "";

          Alert.show("Thank you for your Booking.An E Mail has been sent to your E Mail Address Box.", "Success", Alert.OK);
          } else {
          // else you encountered an error while submitting to the server.
          Alert.show("Unable to process your comments at this time.", "Server Error", Alert.OK);
          }
          };
          • 2. Contact Form - mandatory Fields
            CipiClaudiu Level 1
            Thank You for writing.
            I have to say this is not working ... maybe I haven't placed it right ..

            Here you can see the contact form structure
            http://4webdesign.biz/temp/vinod/test/ascontact.html

            Note! the submit button is having as on it.

            Feel free to decompile the swf to take a better look at it.

            I will apreciate it if you'd help me .. I really need help with this
            • 3. Re: Contact Form - mandatory Fields
              __smileHare
              I thought 2F was writing on AS3.
              You have to use a LoadVars to connect a ASP/PHP file, and let the ASP/PHP file request variables from your SWF, then sends mails by the file.
              • 4. Re: Contact Form - mandatory Fields
                CipiClaudiu Level 1
                well, it is connected to asp and php files .... things is this contact form I bought over the internet and since I'm not good with programming I tought someone might be able to help me with this.

                So form what I understand, the php file should control the swf file to check the empty fields?