Skip to main content
New Participant
March 31, 2014
Question

New to Forums, need someone to doublecheck my code?

  • March 31, 2014
  • 1 reply
  • 351 views

Hi so im writing code for school and for some reason i can't get it to work. Its basically two text boxes that you type in a password twice and it says Invalid, doesnt match, or Password works just fine. If anyone can be of any help id greatly appreciate it!

I also have a link for the fla file in progress if itd make more sense to look at. I dont know if its allowed but heres the link from my dropbox:

https://www.dropbox.com/s/0fq65wc0b3le86b/Password%20Verifier%20%28START%29.fla

password1_txt.addEventListener(Event.CHANGE,ClearFeedback);

password1_txt.addEventListener(Event.CHANGE,ClearFeedback);

function ClearFeedback(e:Event):void {

          feedback_txt.text = "Watch for feedback here.";

          feedback_txt.textColor = 0x3399FF;

}

submit_btn.addEventListener(MouseEvent.CLICK,Submit);

function Submit(e:MouseEvent):void {

          var pass1:String = password1_txt.text;

          var pass2:String = password2_txt.text;

          if (Same(pass1, pass2) == true) {  //Same verifies that the same password was entered both times

                    if (PasswordApproved(pass1) == true)  {

                              // PasswordApproved verifies that the password meets specified standards

                              feedback_txt.text = "Your password was APPROVED."

                              feedback_txt.textColor = 0x00FF00;

                    } else {

                              feedback_txt.text = "DID NOT MEET QUALIFICATIONS. Try again."

                              feedback_txt.textColor = 0xFF0000;

                    }

          } else {

                    feedback_txt.text = "Passwords DID NOT MATCH. Try again."

                    feedback_txt.textColor = 0xFF0000;

          }

          password1_txt.text = "";

          password2_txt.text = "";

          stage.focus = password1_txt;

}

function Same(abc:String, xyz:String):Boolean{

          if (abc == xyz){

                    return (true);

          };

          return (false);

}

function PasswordApproved(e:String){

          var pass5:Number;

          var pass6:int;

          var pass1:Boolean;

          var pass2:Boolean;

          var pass3:Boolean;

          var pass4:Boolean;

          if ((((e.length < 6)) || ((e.length > 10)))){

                    pass1 = false;

          };

          pass6 = 0;

          while (pass6 < e.length) {

                    pass5 = e.charCodeAt(pass6);

                    if ((((pass5 >= 48)) && ((pass5 <= 57)))){

                              pass4 = true;

                    };

                    if ((((pass5 >= 65)) && ((pass5 <= 90)))){

                              pass3 = true;

                    };

                    if ((((pass5 >= 65)) && ((pass5 <= 90)))){

                              pass2 = true;

                    };

                    pass6++;

          };

          if (((((((pass1) && (pass2))) && (pass3))) && (pass4))){

                    return (true);

          };

          return (false);

}

This topic has been closed for replies.

1 reply

Ned Murphy
Brainiac
March 31, 2014

Whyy are you assigning the same event listener twice at the very start?

Why are you declaring all the pass# variables in the PasswordApproved function?

Why are you using an excess of parentheses in your conditionals at the end?

New Participant
March 31, 2014

from function Same down is my work, the top was already created for the assignment. the pass# variables was the only thing i could think of for variables at the time. and the parentheses is our instructors methods i do agree it is strange...