Использование, если еще как сравнить ценность в JS

<!doctype html>
<html>

<head>
  <script type="text/javascript">
    /*<![CDATA [*/
    function myFunction() {
        var answer = document.getElementById('answer');
        if (answer == 10)
          document.getElementById("valid").innerHTML = "Correct!";
        else
          document.getElementById("valid").innerHTML = "Please, Try Again!";
      }
      /* ]]> */
  </script>
</head>

<body>
  <h2>What is 3+7=?</h2>
  <form>
    <input type="text" id="answer">
    <input type="submit" onClick="myFunction(); return false;">
  </form>
  <div id="valid"></div>
</body>

</html>
 Run code snippetHide results
Drab Dormouse