jquery验证省市级联

//ddlProvince省份,ddlCity市,txtAddress详细地址

        function checkAddress() {

            var provinceid = $("[name$='ddlProvince']").get(0).selectedIndex;
            var cityid = $("[name$='ddlCity']").get(0).selectedIndex;
            var name = jQuery.trim($("[name$='txtAddress']").val());
            var chkFlg = true;
            if (provinceid == 0) {
                ShowError("CompanyAddress", "您必须对“省”进行选择!");
                chkFlg = false;
            } else if (cityid == 0) {
                ShowError("CompanyAddress", "您必须对“市”进行选择!");
                chkFlg = false;
            } else if (name == null || name == "") {
                ShowError("CompanyAddress", "请填写公司详细地址!");

                chkFlg = false;
            } else if (name != "" && name.length > 50) {
                ShowError("CompanyAddress", "公司地址不能多于50字!");

                chkFlg = false;
            } else {
                NoneError("CompanyAddress");
                chkFlg = true;
            }
            return chkFlg;
        }

posted @ 2010-12-16 22:53  rains  阅读(807)  评论(0编辑  收藏  举报