JS判断Gridview

 function chkDetailValid() {
            var gv = document.getElementById("gvDetail");
            for (var i = 0; i < gv.rows.length; i++) {
                var txtAC = gv.rows[i].cells[7].getElementsByTagName("input")[0];
                var txtLoc = gv.rows[i].cells[8].getElementsByTagName("input")[0];
                var txtDept = gv.rows[i].cells[9].getElementsByTagName("input")[0];
                if (txtAC != null) {
                    if (txtAC.value == '') {
                        alert("<%=localize.lblCOA + localize.IsNotAllowNull%>"); //会计科目代码不能为空。
                        txtAC.focus();
                        return false;
                    }
                }

                if (txtLoc != null) {
                    if (txtLoc.value == '') {
                        alert($("#lblLocationTitle").html() + "<%=localize.IsNotAllowNull %>"); //不能为空。
                        txtLoc.focus();
                        return false;
                    }
                }

                if (txtDept != null) {
                    if (txtDept.value == '') {
                        alert($("#lblDeptTitle").html() + "<%=localize.IsNotAllowNull %>"); //不能为空。
                        txtDept.focus();
                        return false;
                    }
                }
                var vatInvoice = obj.value;
                if (vatInvoice != '')
                    var xmlURL = "JsonData.ashx?t=IV&val=" + vatInvoice;
                $.get(xmlURL, {}, function(result) {
                    if (result == "N") {
                        alert("<%= localize.lblVatInvoice + localize.IsExists%>"); //發票號碼已經存在。
                        obj.value = '';
                        obj.focus();
                        return false;
                    }
                }, "text");
            }

            return true;
        }

posted @ 2014-08-15 10:03  画风  阅读(203)  评论(0编辑  收藏  举报