Javascript examples for DOM HTML Element:Input Text
Check input text field value with if statement
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function guess() {/*w w w.j a v a 2 s. c o m*/ var x = document.getElementById("magic").value; var word = "please"; if (x == word) { console.log("You entered the magic word!"); } else { console.log("Please try again!"); } } </script> </head> <body> What is the magic word? <br> <input type="text" id="magic" onblur="guess()"> </body> </html>