-3

我基本上是在尝试让用户输入的值被检查并确认它是一个介于 10 和 100 之间的数字,一旦确认存储到变量“num2”中 - 谢谢

<!DOCTYPE html>
<html>
<body>

    <script type ="text/javascript">
    <!--
      function numcheck(pass) {
      var num2 =0;
      isNan()= numcheck(pass);

    if (isNan() == true)
    {
    alert("You can only enter a number in the text field");
    }
    else if (isNan() <=10 || isNan(p) >=100)
    {
    alert ("You must enter a number between 10 and 100");
    }
    else
    num2 = inNan();
    alert ("You have entered var2" + "which has now been stored, thankyou");
    return num2;
     -->
    </script>
    Number: <input type = “text” name = “numcheck” />
    <button onClick="numcheck();"/> Enter </button>
    </body>
    </html>
4

1 回答 1

2
   <!DOCTYPE html>
   <html>
   <header>
   <script>
  function numcheck() {
  var var2 = document.getElementById('num').value;

       if (isNaN(var2)){
        alert("You can only enter a number in the text field");
        document.getElementById('num').value = "";
        }
        else if ( var2 <=10 || var2 >=100){
        alert ("You must enter a number between 10 and 100");
        document.getElementById('num').value = "";
        }
        else{
            alert("You have entered "+ var2 + " which has now been stored, thankyou!");
            document.getElementById('num').value = "";
        }
    }

   </script>

Number: <input type="text" name="numcheck" id="num" />
<button onclick="numcheck()"/> Enter </button>
</body>
</html>

我不确切知道问题是什么,但我只是这样做希望它澄清用户正在寻找什么。

<!-- -->如果您想评论 javascript try // 或 /**/也可以是 html 评论

于 2013-08-17T04:36:33.743 回答