How to check the value of input [closed]

If your input entries have ID’s, you can select the input entry in JavaScript and get the value in the box using
document.getElementById(id).value then simply code the logic to check if the answer is correct based on this value.

If you want to have buttons do something, firstly your button needs to have an onclick attribute like so:
<button onclick='myFunction();'></button>
then in JavaScript the function looks like this:

function myFunction(){

}

Everything inside the { } brackets will be executed AFTER pressing the button. This is where you will need to get your .value and compare with your answer.

Leave a Comment