0 Replies Latest reply on Apr 21, 2008 1:34 PM by brian914

    Help with my form

    brian914 Level 1
      I have the following form validation function that I need to get my input text into.
      I think everything should work, except, I don't know how I get the info from my input text fields into the validation function? Do I need to give the input text boxes an instance name or a var name?

      Right now my input text boxes have the following names:
      tf_Name
      tf_Subject
      tf_Email
      tf_Msg

      I thought I could do something like this, but it did not seem to work?
      validateForm(tf_Name, tf_Subject, tf_Email, tf_Msg);

      This is the function I have:
      function validateForm(tName:String, tSubject:String, tEmail:String, tMsg:String):Void {
      if (tName == "" || tName == undefined) {
      this.showAlertMsg("Please enter your name");
      } else if (tEmail == "" || tEmail == undefined || tEmail.indexOf("@") == -1 || tEmail.indexOf(".") == -1) {
      trace("Invalid email address: "+tEmail+" infexOf1: "+ tEmail.indexOf("@")+ " indexOf2: "+tEmail.indexOf("."));
      this.showAlertMsg("Invalid email address");
      } else if (tSubject == "" || tSubject == undefined) {
      this.showAlertMsg("Please enter a subject");
      } else if (tComments == "" || tComments == undefined) {
      this.showAlertMsg("Please enter some comments");
      } else {
      var e = new LoadVars();
      e.Name = tName;
      e.FromEmail = tEmail;
      e.Subject = tSubject;
      e.Comments = tMsg;
      e.status = "";
      e.sendAndLoad("sendContact.php", e, "Post");
      this.showAlertMsg("Your message has been sent");
      }
      }
      function showAlertMsg(msg:String):Void {
      this.tf_comments.text = "";
      this.tf_comments.text = msg;
      }



      Thanks a lot for any help!