<script language="javascript">
function checkInput()
{
if (document.form1.sx.value*1<=document.form1.dx.value*1)
         {
          alert("上限必须大于底限,请核实!");
          document.form1.sx.focus();
          return false;
          }
}
</script>
<form name="form1" id="form1" method="post" action="1.php" onSubmit="return checkInput()">
上限:<input type=text name="sx" size=10 >
底限:<input type=text name="dx" size=10 >
 <input type=submit name="ok" value="提交">
 </form>
转成数字类型比较就可以了。

解决方案 »

  1.   

    或者是这样
    <script language="javascript">
    function checkInput()
    {
    if (Math.round(document.form1.sx.value)<=Math.round(document.form1.dx.value))
             {
              alert("上限必须大于底限,请核实!");
              document.form1.sx.focus();
              return false;
              }
    }
    </script>
    <form name="form1" id="form1" method="post" action="1.php" onSubmit="return checkInput()">
    上限:<input type=text name="sx" size=10 >
    底限:<input type=text name="dx" size=10 >
     <input type=submit name="ok" value="提交">
     </form>
      

  2.   

    类型问题,默认document.form1.sx.value是String,String比较的结果当然是这样了
    使用valueOf()转换
    script language="javascript">
    function checkInput()
    {
    if (document.form1.sx.value.valueOf()<=document.form1.dx.value.valueOf())
             {
              alert("上限必须大于底限,请核实!");
              document.form1.sx.focus();
              return false;
              }
    }
    </script>