我基本上是在尝试让用户输入的值进行检查,并确认它是一个介于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>
<!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注释