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

js判断大小问题
代码:
<input type="text" name="user.startNo" style="width: 155px;" id="startNo" 
  onblur="check_Name(this,document.forms[0].endNo)"/>
  <input type="text" name="user.endNo" style="width: 155px;" id="endNo"
  onblur="check_Name(document.forms[0].startNo,this)"/>

js:
function check_Name(se,ne){
if((parseInt(document.getElementById("startNo").value)) < (parseInt(document.getElementById("endNo").value))){
alert("1223");
  /* 要的效果是:
  int startNo=99;
  int endNo=100;
  if(startNo<endNo){
  alert("我愁了,不及格程序猿");
  }
}
}

这样判断大小,根本没效果?

------解决方案--------------------
直接alert(parseInt(document.getElementById("startNo").value)看看是什么

------解决方案--------------------
探讨
引用:
直接alert(parseInt(document.getElementById("startNo").value)看看是什么

正确值,要是
((parseInt(document.getElementById("startNo").value)) < 2000(这个为数字))
也能正常执行。就是2个文本的值不能执行

------解决方案--------------------
HTML code

<input type="text" name="user.startNo" style="width: 155px;" id="startNo" onblur="check_Name()"/> 
<input type="text" name="user.endNo" style="width: 155px;" id="endNo" onblur="check_Name()"/>

function check_Name(){
    if((parseInt(document.getElementById("startNo").value)) < (parseInt(document.getElementById("endNo").value))){
        alert("1223");
    }
}

------解决方案--------------------
探讨
引用:
直接alert(parseInt(document.getElementById("startNo").value)看看是什么

正确值,要是
((parseInt(document.getElementById("startNo").value)) < 2000(这个为数字))
也能正常执行。就是2个文本的值不能执行