3 Replies Latest reply on Aug 18, 2008 9:45 AM by Newsgroup_User

    Submit Butting Not Working when Validation Code is Run

    Kat19762203
      Hello everyone!

      I would like to thank everyone who helps now, just incase I forget to thank them later.

      I've been working on a form which gathers a persons name, phone number, and event type and submits it to my email address (its for a catering business). Everything was working until I added some validation code that would ensure people were filling in the form, so I wouldn't get blank emails.

      The Validation Code that I have currently is:

      function formValidationChecks(){
      import mx.controls.Alert;
      if (name_txt.length==0){
      _global.styles.Alert.setStyle("color", 0x000099);
      Alert.show("Name is a required field.", "Warning");
      Selection.setFocus("name_txt");
      }
      else if (phone_txt.length==0){
      _global.styles.Alert.setStyle("color", 0x000099);
      Alert.show("phone is a required field.", "Warning");
      Selection.setFocus("phone_txt");
      }
      else if (event_txt.length==0){
      _global.styles.Alert.setStyle("color", 0x000099);
      Alert.show("Event is a required field.", "Warning");
      Selection.setFocus("event_txt");
      }

      }

      Once the form is filled in and the user hits the submit button, additional code is run:

      on (release) {
      if(formValidationChecks()){
      mySendVars = new LoadVars();
      mySendVars.name = name_txt.text;
      mySendVars.phone = phone_txt.text;
      mySendVars.event = event_txt.text;
      mySendVars.email = "myemail@mysemail.com";
      mySendVars.send("sendmail.asp", "_self", "POST");
      }

      }

      As everything is now, if I don't fill in any of the fields, it spits back my warning message, but if everything is filled in, and hit the submit button, nothing happens, no email.....

      It's become frustrating.....any help, it would be greatly appreciated!