x
 
<!DOCTYPE html>
<html>
<body>
<p>请输入一个 1 到 10 之间的数字:</p>
<input id="numb" type="text">
<button type="button" onclick="myFunction()">提交</button>
<p id="demo"></p>
<script>
function myFunction() {
  var x, text;
  // 获取 id="numb" 的输入字段的值
  x = document.getElementById("numb").value;
  // 如果 x 不是数字或小于 1 或大于 10,则输出 "Input not valid"
  // 如果 x 是 1 到 10 之间的数字,则输出 "Input OK"
   
  if (isNaN(x) || x < 1 || x > 10) {
    text = "Input not valid";
  } else {
    text = "Input OK";
  }
  document.getElementById("demo").innerHTML = text;
}
</script>
</body>
</html>