Skip to content

Instantly share code, notes, and snippets.

@Octagon-simon
Created October 25, 2021 18:15
Show Gist options
  • Select an option

  • Save Octagon-simon/8fc312a52e067df2894ce1dbfeb26363 to your computer and use it in GitHub Desktop.

Select an option

Save Octagon-simon/8fc312a52e067df2894ce1dbfeb26363 to your computer and use it in GitHub Desktop.
function checkAnswer(x = "this") {
var answer = 25;
var userAnswer = x.value;
if(userAnswer.length >= 2){
if(userAnswer != answer) {
alert('You have provided an invalid Answer');
}
}
}
document.addEventListener('DOMContentLoaded', (event) => {
//Add an Input Event
document.querySelector('#inp_answer').addEventListener('input', function() {
checkAnswer(this);
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment