0

How to make an alert window show after the right words has been inputted In the box and the disabled button can be clicked

<label for="fname">code</label> <input type="text" id="v" name="firstname" placeholder="code" onkeyup="f()" required> <button id="btn1" onclick="f()" disabled>Try it</button> function f() { var i; var a = [ "Q", 1]; var p = document.getElementById("v").value; var c = document.getElementById("btn1"); c.disabled = true; for(var i = 0; i < a.length; i++) { if (a[i] == p) { c.disabled = false; document.getElementById("no").innerHTML = "Congrats" + m; } } }

3rd May 2018, 1:42 PM
klisco1
1 Answer
+ 1
i guess this: <label for="fname">code</label> <input type="text" id="code" name="firstname" placeholder="code" onkeyup="f()" required> <button id="btn1" onclick="f()" disabled>Try it</button> function f() { var answers = [ "Q", 1]; var input = document.getElementById("code").value; var btn = document.getElementById("btn1"); for(var i=0; i<answers.length; i++) { if (answers[i] == input) { btn.disabled = false; alert("Congrats"); } } }
9th Jun 2018, 7:29 PM
Ask Plays
Ask Plays - avatar