日期:2014-05-20  浏览次数:20619 次

javascript 中文本框中数字怎么比较
<input id="toplimit1" type="text" name="shangxian" width="10%" value="8000"/>
<input id="bottomlimit1" type="text" name="xiaxian" width="10%" value="13000"/>
var bottomlimit = document.getElementById("bottomlimit2").value.valueOf();
var toplimit = document.getElementById("toplimit2").value.valueOf();
alert(bottomlimit);
alert(toplimit);
alert(bottomlimit<toplimit);
alert(bottomlimit>toplimit);
为什么是true

------解决方案--------------------
var bottomlimit = document.getElementById("bottomlimit2").value.valueOf();
var toplimit = document.getElementById("toplimit2").value.valueOf();
var b=parseInt(bottomlimit );
var t=parseInt(toplimit );
alert(b<t);
alert(t>b);