Skip to main content
bumbies
Known Participant
Jul 7, 2021 8:55 AM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

    4 replies

    bumbies
    bumbiesAuthor
    Known Participant
    Jul 7, 2021 9:03 AM UTC

    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.

    Translate
    kglad
    Community Expert
    Community Expert
    Jul 8, 2021 5:59 AM UTC

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

    Translate
    bumbies
    bumbiesAuthor
    Known Participant
    Jul 8, 2021 9:09 AM UTC

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

    Translate