Skip to main content
bumbies
Known Participant
July 7, 2021
Question

Adobe Animate CC HTML5 - Validate multiple buttons & textinput boxes with button

  • July 7, 2021
  • 1 reply
  • 572 views

I am trying to create a question that checks if the user has selected multiple buttons & entered textinput boxes correctly. Checking all these only when user clicks a submit button.

 

Based on this thread I am able to check if multiple buttons have been selected & maintained at a button down state on. It will check if the multiple button are selected, but it moves on automatically if any buttons are selected. How do I define which buttons are correct/wrong and to check only upon clicking on a button?

 

I am able to check if user has made multiple correct textinputs based on this thread.

 

I need help to combine these codes.

Any advice or help would be great! Thank you!

    This topic has been closed for replies.

    1 reply

    bumbies
    bumbiesAuthor
    Known Participant
    July 7, 2021

    Here's the code ref:

    // Multiple button selected with state on, checks & moves on automatically if any 3 buttons are selected:
    this.count = 0;
    this.totalToGo = 3;
    
    this.check = function(e)
    {
    if (!e.currentTarget.selected)
    {
    this.count++;
    e.currentTarget.selected= true;
    e.target.removeAllEventListeners();
    }
    if (this.count == this.totalToGo)
    this.gotoAndStop(5);
    };
    this.stop();
    this.b1.on("click", this.check, this);
    this.b2.on("click", this.check, this);
    this.b3.on("click", this.check, this);
    
    this.b4.on("click", this.check, this); // how to define this b4 is a wrong option?

     

    I am also able to check if user has made multiple correct textinputs.

    var root = this;
    
    function validateF(){
    if($("#answer1").val()=="123" && $("#answer2").val()=="234"){
    // correct
    root.gotoAndStop("correctProceed");
    } else {
    // incorrect
    root.gotoAndStop("wrongTryAgain");
    }
    }
    this.start.addEventListener("click", validateF);

     

    Need help : To combine these codes to check if the user has clicked multiple buttons correctly & entered multiple textinput boxes correctly. Checking all these only when user clicks a submit button.

    kglad
    Community Expert
    Community Expert
    July 8, 2021

    first check if all buttons have been selected and, if they are, then check all the text inputs 

    bumbies
    bumbiesAuthor
    Known Participant
    July 8, 2021

    Thank you kglad for your advice! Can you please provide some code reference? I am still having some difficulty getting it to work...