1 Reply Latest reply on Dec 8, 2006 12:47 PM by kglad

    check box w/validation form troubles

    hutch-diggens Level 1
      hello there, I am under a major, major Deadline!
      I have a flash and php contact form with a validation made with all input text boxes. I need to add 1 check box to the form, but I don't know how to pass it to through.

      here is the code I have for my form now.

      function checkForm():Boolean {
      // this checks whether required fields have been filled in
      // initialize missing flag on assumption everything OK
      var missing:Boolean = false;
      // clear all error text fields
      error1_txt.text = error2_txt.text=error3_txt.text="";
      // check each field
      // if problem is encountered, display message
      // and set missing flag to true
      if (text_field_1.text == "") {
      error1_txt.text = "Please enter your name";
      missing = true;
      }
      if (text_field_2.text.indexOf("@") == -1) {
      error2_txt.text = "Please enter a valid email address";
      missing = true;
      }
      if (text_field_5.text == "") {
      error3_txt.text = "You have not entered any comments";
      missing = true;
      }
      // if missing is true, return false
      // otherwise return true
      return missing ? false : true;
      }
      function sendMessage():Void {
      // check whether form has been correctly filled in
      var formOK:Boolean = checkForm();
      // if no problems, process the form and send variables to PHP script
      if (formOK) {
      // Form processing goes here
      message.from = text_field_1.text;
      message.email = text_field_2.text;
      message.comments = text_field_5.text;
      message.sendAndLoad("feedback.php?ck="+ new Date().getTime(), messageSent);
      // display message informing user that email is being sent
      gotoAndStop("sending");
      }
      }
      function backToForm():Void {
      // send playhead back to the main form
      gotoAndStop("theForm");
      }
      // create and apply text format for date
      var dateDisplay:TextFormat = new TextFormat();
      dateDisplay.font = "Georgia,Times,_serif";
      theDate_txt.setNewTextFormat(dateDisplay);
      theDate_txt.autoSize = "left";
      // create LoadVars instance to retrieve date from PHP script
      var getDate:LoadVars = new LoadVars();
      // initialize LoadVars to send form data
      // and receive response from the PHP script
      var message:LoadVars = new LoadVars();
      var messageSent:LoadVars = new LoadVars();
      // load date from PHP
      getDate.load(" http://localhost/phpflash/ch02/today2.php");
      // assign theDate property of the LoadVars instance to text field
      getDate.onLoad = function() {
      theDate_txt.text = this.theDate;
      };
      messageSent.onLoad = function() {
      if (this.sent == "OK") {
      gotoAndStop("acknowledge");
      } else {
      gotoAndStop("failure");
      failure_txt.text = this.reason;
      }


      };
      gotoAndStop("theForm");


      any help would be greatly appreciated.
      thanks,
      hutch