4 Replies Latest reply on Sep 13, 2006 3:37 PM by Angyl

    form validation

      How do I get a message to disply when a user has left one or more of the form fields empty???
        • 1. form validation
          Angyl Level 1
          Name your field and (optional) create a blank dynamic text field named for the error message

          function checkForm():Boolean {
          var missing:Boolean = false;
          error1._txt.text = " ";
          if (name_txt.text == "") (
          error1._txt.text = "Please enter your name";
          missing = true;
          return missing ? false : true;

          function sendMessage():Void {
          //check whether the form has been correctly field in
          var formOK:Boolean = checkForm();}
          • 2. Re: form validation
            Brad8888 Level 1
            Thanks...I got these errors...
            **Error** Symbol=BuySquares, layer=Layer 14, frame=38:Line 5: ')' expected
            error1._txt.text = "Please enter your name";

            **Error** Symbol=BuySquares, layer=Layer 14, frame=38:Line 1: Statement must appear within on handler
            function checkForm():Boolean {

            Total ActionScript Errors: 2 Reported Errors: 2

            Is Boolean some kind of actionscript code or is it just a symbol from your document?
            Cheers...a bit confused

            • 3. Re: form validation
              Angyl Level 1
              Oops. My typo.
              if (name_txt.text == "")
              you should have a bracket { instead of an open parenthesis (
              and use a second closed bracket } after

              missing = true;

              The other error is because you apparently attached this to the symbol BuySquares you're using. This code attaches to the frame, not the mc.
              • 4. form validation
                Angyl Level 1