第二个input type="number"的值不能超过第一个input type="number" maxlength="3"的值

The value of second input type="number" cannot be exceed to the value of the first input type="number" maxlength="3"

这是测试代码,不使用按钮,如果值 <= 第一个文本框,第二个文本框将接受数字。

<html>
<body>

<input id="first" name="first" type="number" maxlength = "3">

<input id="second" name="second" type="number" maxlength = "3"      onblur="compare()" >


</body>
</html>

<script type="text/javascript">

function compare()
{
 var firstNumber = document.getElementById("first").value;
 var secondNumber = document.getElementById("second").value;
 if(firstNumber >= secondNumber)
 {
  //nothing will do, continue to the 3rd textbox.
 }
 else
 {
 alert("The number you enter is larger than the first one.");
  //clear the value of the second textbox
 }
}

</script>

如果我理解正确,您没有收到任何错误,但您希望对两个输入进行比较。

您将不得不使用 javascript。您需要将每个输入存储在一个变量中。然后你需要编写一个函数来比较这些变量的值并显示输出。

例如:

<button type="button" onclick="compare()">Compare!</button>

<script>

function compare()
{
 var firstNumber = document.getElementById("first").value;
 var secondNumber = document.getElementById("second").value;
 if(firstNumber == secondNumber)
 {
  alert("The numbers are equal");
 }
 else if(firstNumber > secondNumber)
 {
  alert("The first number is larger");
 }
 else
 {
  alert("The second number is larger");
 }
}

</script>

然后根据您希望发生的情况,将您自己的代码放在第二个数字较大的位置。

编辑:抱歉,如果您想要经典版本 ASP。我相信无论如何你都能将它翻译成它。