js中比较两个页面取到的值出问题

页面中的一段js方法

function checkCountS(countSend){
            var countStore = $("#countStore").val();
            if(countSend>countStore){
                $("#span3").html("<font color='red'>配送数量不能大于库存数量</font>");
                $("#save").attr("disabled",true);
                //$("#countSend").val("");
            }else{
                $("#span3").html("");
                $("#save").attr("disabled",false);
            }
        }

此时当countSend取值明明小于countStore时也会进入第一个if判断中

解决办法如下:

function checkCountS(countSend){
            var countStore = $("#countStore").val();
            var cst = parseInt(countStore);
            var cs  = parseInt(countSend);
            if(cs>cst){
                $("#span3").html("<font color='red'>配送数量不能大于库存数量</font>");
                $("#save").attr("disabled",true);
                //$("#countSend").val("");
            }else{
                $("#span3").html("");
                $("#save").attr("disabled",false);
            }
        }

posted @ 2014-01-10 18:59  jiangxuehaibo  阅读(144)  评论(0编辑  收藏  举报