8 Replies Latest reply on Jan 24, 2008 7:12 AM by kglad

    Validation almost working

    E.S.D.
      Hi all!

      I have tried altering my validation script a bit but it comes up with "Please enter your emailaddress" The whole time, even if the name field is not filled in. The scripting is as follows ...

      on (press) {
      validname = "0";
      validphone = "0";
      validemail = "0";
      validmessage = "0";

      if (Number(length(name)) >= 3) {
      validname = "10";
      } else {
      info = "Oops! Missing informations about your name";
      }
      // end if
      if (Number(length(phone)) <= 10) {
      validphone = "10";
      } else {
      info = "Please type in your full Tel / Cell Number";
      }
      // end if
      if (Email == "" || Email.indexOf("@") == -1 || Email.indexOf(".") == -1) {
      validemail = "10";
      } else {
      info = "Please enter your emailaddress";
      }
      // end if
      if (Number(length(comments)) >= 5) {
      validmessage = "10";
      } else {
      info = "Please type in your Query / Comment";
      }
      // end if
      }

      Please help! Thanks!
        • 1. Re: Validation almost working
          kglad Adobe Community Professional & MVP
          use trace(Email) to debug.
          • 2. Re: Validation almost working
            E.S.D. Level 1
            I have never used the trace expression before -- i know bad hey -- so how do i go about checking?
            • 3. Re: Validation almost working
              kglad Adobe Community Professional & MVP
              :

              • 4. Re: Validation almost working
                E.S.D. Level 1
                Cool, thanks, it came out as undefined - so does this mean that i have a conflict in my script with regard to the name of the text field?
                • 5. Re: Validation almost working
                  kglad Adobe Community Professional & MVP
                  it means you're probably using a movieclip button and need to use something like _parent.Email.

                  you can use trace(this) on the timeline where Email is defined and use trace(this) in your on(press) method to see the relative and absolute paths between the two.
                  • 6. Re: Validation almost working
                    E.S.D. Level 1
                    What can i change to make the button a "button" and not a "movieclip button"? So that i dont need the _parent.Email function ....
                    • 7. Re: Validation almost working
                      E.S.D. Level 1
                      Ok i traced all my fields and they are all working acc to the scripting. Only thing causing a problem now, is the error message ... it stays on "Please enter your name", even if i have entered it. Here is the scripting ... Thanx!

                      on (press) {

                      trace(name);

                      validname = "0";
                      validphone = "0";
                      validemail = "0";
                      validmessage = "0";

                      if (Number(length(name)) >= 3) {
                      validname = "10";
                      } else {
                      info = "Oops! Missing informations about your name";
                      }
                      // end if
                      if (Number(length(phone)) <= 10) {
                      validphone = "10";
                      } else {
                      info = "Please type in your full Tel / Cell Number";
                      }
                      // end if
                      if (email == "" || email.indexOf("@") == -1 || email.indexOf(".") == -1) {
                      validemail = false;
                      } else {
                      info = "Please enter your emailaddress";
                      }
                      // end if
                      if (Number(length(message_t)) >= 5) {
                      validmessage = "10";
                      } else {
                      info = "Please type in your Query / Comment";
                      }
                      // end if

                      if (NameValid || EmailValid || PhoneValid || MessageValid) {
                      getURL("orderform.php", "_parent", "POST");
                      }
                      // end if
                      }
                      • 8. Re: Validation almost working
                        kglad Adobe Community Professional & MVP
                        there's nothing in your code that would generate "Please enter your name".

                        are you seeing "Oops! Missing informations about your name"? if so, use the trace() function in your if-statement to see why it thinks the length of name is less than 3.