easyui asp.net uploadify使用列表验证方法

来源:互联网 发布:java软件开发好学吗 编辑:程序博客网 时间:2024/06/11 22:34


<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>打印宗目录</title>
    <link href="../Javascript/jquery-easyui-1.4/themes/default/easyui.css" rel="stylesheet" />
    <link href="../Javascript/jquery-easyui-1.4/themes/icon.css" rel="stylesheet" />
    <link href="../Javascript/jquery-easyui-1.4/themes/demo.css" rel="stylesheet" />
    <script src="../Javascript/jquery-1.7.2.min.js"></script>
    <script src="../Javascript/jquery-easyui-1.4/jquery.easyui.min.js"></script>
    <script src="../Javascript/jquery-easyui-1.4/datagrid-filter.js"></script>
    <script src="../Javascript/jquery-easyui-1.4/datagrid-detailview.js"></script>
    <script src="../Javascript/jquery-easyui-1.4/locale/easyui-lang-zh_CN.js"></script>
    <script src="../Javascript/uploadify/jquery.uploadify.js"></script>
    <link href="../Javascript/uploadify/uploadify.css" rel="stylesheet" />
</head>

<body>
    <form id="form1" runat="server">
        <div>
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="SaveSL()" style="float: left; margin-left: 5px; margin-bottom:5px;">保存</a>
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-print'" onclick="RturnFY()" style="float: left; margin-left: 20px; margin-bottom:5px;">打印受理凭证</a>
        </div>
        <div class="easyui-panel" title="土地基本信息" style="width: 100%;">
            <table style="width: 100%;">
                <tr>
                    <td style="float: right; margin: auto;">姓名(名称):</td>
                    <td>
                        <input id="txt_xm" class="easyui-validatebox easyui-textbox" required="true" validType="CHS"  style="width: 300px; height: 27px; float: left;" /></td>
                    <td style="float: right; margin: auto;">证件类型:</td>
                    <td>
                        <input id="cb_zjlx" class="easyui-combobox" style="width: 300px; height: 27px; float: left;"
                            name="language"
                            data-options="
     url:'../Common/ComboxHelp.ashx?type=1',
     method:'get',
     valueField:'id',
     textField:'text',
     panelHeight:'auto'
   " /></td>
                </tr>
                <tr>
                    <td style="float: right; margin: auto;">证件号码:</td>
                    <td>
                        <input id="txt_zjhm" class="easyui-textbox" style="width: 300px; height: 27px; float: left;" /></td>
                    <td style="float: right; margin: auto;">电话号码:</td>
                    <td>
                        <input id="txt_dhhm" class="easyui-validatebox easyui-textbox" required="true" validType="mobile"  style="width: 300px; height: 27px; float: left;" /></td>
                </tr>

            </table>
        </div>
        <div class="easyui-panel" title="代理人基本信息" style="width: 100%;">
            <table style="width: 100%;">
                <tr>
                    <td style="float: right; margin: auto;">代理人:</td>
                    <td>
                        <input id="txt_dlr" class="easyui-textbox" style="width: 300px; height: 27px; float: left;" /></td>
                    <td style="float: right; margin: auto;">证件类型:</td>
                    <td>
                        <input id="cb_dlrzjlx" class="easyui-combobox" style="width: 300px; height: 27px; float: left;"
                            name="language"
                            data-options="
     url:'../Common/ComboxHelp.ashx?type=1',
     method:'get',
     valueField:'id',
     textField:'text',
     panelHeight:'auto'
   " /></td>
                </tr>
                <tr>
                    <td style="float: right; margin: auto;">证件号码:</td>
                    <td>
                        <input id="txt_dlrzjhm" class="easyui-textbox" style="width: 300px; height: 27px; float: left;" /></td>
                    <td style="float: right; margin: auto;">电话号码:</td>
                    <td>
                        <input id="txt_dlrdhhm" class="easyui-textbox" style="width: 300px; height: 27px; float: left;" /></td>
                </tr>
                <tr>
                    <td style="float: right; margin: auto;">申请查询类别:</td>
                    <td>
                        <input id="cb_sqcxlb" class="easyui-combobox" style="width: 300px; height: 27px; float: left;"
                            name="language"
                            data-options="
     url:'../Common/ComboxHelp.ashx?type=2',
     method:'get',
     valueField:'id',
     textField:'text',
     panelHeight:'auto'
   " /></td>
                    <td style="float: right; margin: auto;">受理编号:</td>
                    <td>
                        <input id="txt_slbh" class="easyui-textbox" style="width: 300px; height: 27px; float: left;" /></td>
                </tr>
            </table>
        </div>
        <div class="easyui-panel" style="padding: 5px; width: 100%;">
            <table id="sjzj" title="申请材料信息" style="width: 100%; height: 565px" data-options="toolbar:toolbar">
                <thead>
                    <tr>
                        <th data-options="field:'YS',width:120,editor:'text'">提交申请材料</th>
                        <th data-options="field:'CLMC',width:150">件数</th>
                        <th data-options="field:'CLLXCN',width:120">材料介质</th>
                    </tr>
                </thead>
            </table>
        </div>
        <div class="easyui-panel" title="查询信息" style="padding: 5px; width: 100%;">
            <table style="width: 100%;">
                <tr>
                    <td style="float: right; margin: auto;">查询目的或用途:</td>
                    <td>
                        <input id="txt_cxmdhyt" class="easyui-textbox" style="width: 300px; height: 27px; float: left;" /></td>
                    <td style="float: right; margin: auto;">不动产坐落名称:</td>
                    <td>
                        <input id="txt_bdczlmc" class="easyui-textbox" style="width: 300px; height: 27px; float: left;" /></td>
                </tr>
                <tr>
                    <td style="float: right; margin: auto;">不动产权属证书或登记证明号:</td>
                    <td>
                        <input id="txt_bdczmh" class="easyui-textbox" style="width: 300px; height: 27px; float: left;" /></td>
                    <td style="float: right; margin: auto;">查询类别:</td>
                    <td>
                        <input id="cb_cxlb" class="easyui-combobox" style="width: 300px; height: 27px; float: left;"
                            name="language"
                            data-options="
     url:'../Common/ComboxHelp.ashx?type=5&oid=<%=oid %>',
     method:'get',
     valueField:'id',
     textField:'text',
     multiple:true,
     panelHeight:'auto'
   " />
                    </td>
                </tr>
                <tr>
                    <td style="float: right; margin: auto;">登记分类:</td>
                    <td>
                        <input id="cb_djfl" class="easyui-combobox" style="width: 300px; height: 27px; float: left;"
                            name="language"
                            data-options="
     url:'../Common/ComboxHelp.ashx?type=8',
     method:'get',
     valueField:'id',
     textField:'text',
     multiple:true,
     panelHeight:'auto'
   " /></td>
                    <td style="float: right; margin: auto;">查询结果要求:</td>
                    <td>
                        <input id="cb_cxjgyq" class="easyui-combobox" style="width: 300px; height: 27px; float: left;"
                            name="language"
                            data-options="
     url:'../Common/ComboxHelp.ashx?type=6',
     method:'get',
     valueField:'id',
     textField:'text',
     panelHeight:'auto'
   " /></td>
                </tr>
            </table>
        </div>
        <div class="easyui-panel" style="padding: 5px; width: 100%;">
            <table id="bcxxx" title="被查询人信息" style="width: 100%; height: 565px" data-options="toolbar:toolbarsqr">
                <thead>
                    <tr>
                        <th data-options="field:'YS',width:120,editor:'text'">姓名</th>
                        <th data-options="field:'CLMC',width:150">证件类型</th>
                        <th data-options="field:'CLLXCN',width:120">证件号码</th>
                        <th data-options="field:'CLLXCN',width:120">联系电话</th>
                    </tr>
                </thead>
            </table>
        </div>
        <div id="w" class="easyui-window" title="上传文件" data-options="iconCls:'icon-save'" style="width: 500px; height: 280px; padding: 5px;">
            <div class="easyui-layout" data-options="fit:true">
                <div id="File" style="margin-bottom: 20px;">
                    <br />
                    文件名称:<input id="txt_clmc" class="easyui-textbox" style="width: 30%; height: 27px; float: left;" />
                    文件数量:<input id="txt_wjsl" class="easyui-textbox" style="width: 30%; height: 27px; float: left;" />
                    <br />
                    <br />
                    文件类型:<input class="easyui-combobox" style="width: 30%; height: 27px; float: left;"
                        name="language"
                        data-options="
     url:'../Common/ComboxHelp.ashx?type=4',
     method:'get',
     valueField:'id',
     textField:'text',
     panelHeight:'auto'
   " />
                    文件页数:<input id="txt_wjys" class="easyui-textbox" style="width: 30%; height: 27px; float: left;" />
                    <br />
                    <br />
                    上传文件:<div id='uploadify' style="width: 80px;"></div>
                </div>
                <div data-options="region:'south',border:false" style="text-align: right; padding: 5px 0 0;">
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:impInfo();" style="width: 80px">确定</a>
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:$('#w').window('close');" style="width: 80px">关闭</a>
                </div>
            </div>
        </div>
        <div id="r" class="easyui-window" title="上传文件" data-options="iconCls:'icon-save'" style="width: 500px; height: 200px; padding: 5px;">
            <div class="easyui-layout" data-options="fit:true">
                <div id="Div2" style="margin-bottom: 20px;">
                    <br />
                    &nbsp;&nbsp;&nbsp;姓&nbsp;&nbsp;&nbsp;名:<input id="Text13" class="easyui-textbox" style="width: 30%; height: 27px; float: left;" />
                    证件类型:<input class="easyui-combobox" style="width: 30%; height: 27px; float: left;"
                        name="language"
                        data-options="
     url:'../Common/ComboxHelp.ashx?type=1',
     method:'get',
     valueField:'id',
     textField:'text',
     panelHeight:'auto'
   " />
                    <br />
                    <br />
                    证件号码:<input id="Text15" class="easyui-textbox" style="width: 30%; height: 27px; float: left;" />
                    联系电话:<input id="Text16" class="easyui-textbox" style="width: 30%; height: 27px; float: left;" />
                </div>
                <div data-options="region:'south',border:false" style="text-align: right; padding: 5px 0 0;">
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:impInfo();" style="width: 80px">确定</a>
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:$('#r').window('close');" style="width: 80px">关闭</a>
                </div>
            </div>
        </div>
    </form>
    <script type="text/javascript">
        function impInfo()
        {
            alert("保存");
        }
        function AddFile() {
            $("#uploadify").uploadify({
                swf: '../JavaScript/uploadify/uploadify.swf', //上传的Flash,不用管,路径对就行
                uploader: '../Common/CommonHandler.ashx?type=UploadFile', //Post文件到指定的处理文件
                auto: true,
                dataType: "text",
                buttonText: '浏览', //浏览按钮的Text
                cancelImage: 'JavaScript/uploadify/uploadify-cancel.png', //取消按钮的图片地址
                //fileTypeExts: '*.doc;*.docx;*.xls;*.xlsx;*.pdf;*.jpg;*.gif;*.txt;*.mp4;*.mp3;*.avi;*.mov;*.wmv;*.rar;*.zip;*.ppt;*.pptx;*.png;*.tif', //需过滤文件类型的提示
                // height: 28,//浏览按钮高
                // width:52,//浏览按钮宽
                multi: true, //是否允许多文件上传
                // uploadLimit: 999, //同时上传多小个文件
                //queueSizeLimit: 999, //队列允许的文件总数
                removeCompleted: false, //当上传成功后是否将该Item删除
                onSelect: function (file) {
                    var fileName = file.name;
                    if (fileName.length > 100) {
                        alert("文件名称太长上传失败,请修改后重试!");
                        $('#uploadify').uploadifyCancel(file.id);
                    }
                    if (checkStr(fileName)) {
                        alert("文件名称中包含非法字符上传失败,请修改后重试!");
                        $('#uploadify').uploadifyCancel(file.id);
                    }
                }, //选择文件时触发事件
                onSelectError: function (file, errorCode, errorMsg) { }, //选择文件有误触发事件
                onUploadComplete: function (file) { }, //上传成功触发事件
                onUploadError: function (file, errorCode, errorMsg) { }, //上传失败触发事件
                onUploadProgress: function (file, fileBytesLoaded, fileTotalBytes) { }, //上传中触发事件
                onUploadStart: function (file) { }, //上传开始触发事件
                onUploadSuccess: function (event, response, status) {

                }, //当单个文件上传成功后激发的事件
                onSWFReady: function () { }
            });
        }
        $(function () {
            $('#w').window('close');
            $('#r').window('close');
            AddFile();
        })
        var toolbar = [{
            text: '添加申请材料',
            iconCls: 'icon-add',
            handler: function () {
                $("#w").window("open");
            }
        }, '-', {
            text: '删除',
            iconCls: 'icon-cut',
            handler: function () {
                alert("删除");
            }
        }];
        var toolbarsqr = [{
            text: '添加申请人信息',
            iconCls: 'icon-add',
            handler: function () {
                $("#r").window("open");
            }
        }, '-', {
            text: '删除',
            iconCls: 'icon-cut',
            handler: function () {
                alert("删除");
            }
        }];
        var dg = $('#sjzj').datagrid({
            method: "get",
            rownumbers: true, singleSelect: true,
            url: '../DataFactory/DataService.aspx?method=getSJZJ&id=' + $('#hiddYWH').val(),
            autoRowHeight: false,
            pagination: true,
            pageSize: 20,
            pageList: [5, 10, 20, 30, 40, 50],
            sortName: "IDX",
            sortOrder: "asc",
            height: "auto",
            nowrap: true,
            idField: "IDX",
            checkOnSelect: true,
            selectOnCheck: true,
            filterDelay: 500,
            enableFilter: true,
            remoteFilter: true,
            filterBtnIconCls: 'icon-filter',
            detailFormatter: function (index, row) {
                return '<div class="ddv" style="padding:5px 0"></div>';
            }
        });
        var dg = $('#bcxxx').datagrid({
            method: "get",
            rownumbers: true, singleSelect: true,
            url: '../DataFactory/DataService.aspx?method=getSJZJ&id=' + $('#hiddYWH').val(),
            autoRowHeight: false,
            pagination: true,
            pageSize: 20,
            pageList: [5, 10, 20, 30, 40, 50],
            sortName: "IDX",
            sortOrder: "asc",
            height: "auto",
            nowrap: true,
            idField: "IDX",
            checkOnSelect: true,
            selectOnCheck: true,
            filterDelay: 500,
            enableFilter: true,
            remoteFilter: true,
            filterBtnIconCls: 'icon-filter',
            detailFormatter: function (index, row) {
                return '<div class="ddv" style="padding:5px 0"></div>';
            }
        });
        function SaveSL()
        {
            //姓名
            var xm = $('#txt_xm').filebox('getValue');
            //证件类型
            var cb_zjlx = $('#cb_zjlx').combobox('getValue');
            //证件号码
            var zjhm = $('#txt_zjhm').filebox('getValue');
            //电话号码
            var dhhm = $('#txt_dhhm').filebox('getValue');
            //代理人
            var dlr = $('#txt_dlr').filebox('getValue');
            //代理人证件类型
            var dlrzjlx = $('#cb_dlrzjlx').combobox('getValue');
            //代理人证件号码
            var dlrzjhm = $('#txt_dlrzjhm').filebox('getValue');
            //代理人电话号码
            var dlrdhhm = $('#txt_dlrdhhm').filebox('getValue');
            //申请查询类别
            var sqcxlb = $('#cb_sqcxlb').combobox('getValue');
            //受理编号
            var slbh = $('#txt_slbh').filebox('getValue');
            //查询目的或用途
            var cxmdhyt = $('#txt_cxmdhyt').filebox('getValue');
            //不动产坐落名称
            var bdczlmc = $('#txt_bdczlmc').filebox('getValue');
            //不动产权属证书或登记证明号
            var bdczmh = $('#txt_bdczmh').filebox('getValue');
            //查询类别
            var cxlb = $('#cb_cxlb').combobox('getValues');
            //登记分类
            var djfl = $('#cb_djfl').combobox('getValues');
            //查询结果要求 cb_cxjgyq
            var cxjgyq = $('#cb_cxjgyq').combobox('getValue');
            var flag = true;
            $('#form1 input').each(function () {
                if ($(this).attr('required') || $(this).attr('validType')) {
                    if (!$(this).validatebox('isValid')) {
                        flag = false;
                        return;
                    }
                }
            })
            if (flag)
                alert('验证通过!');
            else
                alert('验证失败!');
        }
    </script>
    <script>
        $.extend($.fn.validatebox.defaults.rules, {
            CHS: {
                validator: function (value, param) {
                    return /^[\u0391-\uFFE5]+$/.test(value);
                },
                message: '请输入汉字'
            },
            english: {// 验证英语
                validator: function (value) {
                    return /^[A-Za-z]+$/i.test(value);
                },
                message: '请输入英文'
            },
            ip: {// 验证IP地址
                validator: function (value) {
                    return /\d+\.\d+\.\d+\.\d+/.test(value);
                },
                message: 'IP地址格式不正确'
            },
            ZIP: {
                validator: function (value, param) {
                    return /^[0-9]\d{5}$/.test(value);
                },
                message: '邮政编码不存在'
            },
            QQ: {
                validator: function (value, param) {
                    return /^[1-9]\d{4,10}$/.test(value);
                },
                message: 'QQ号码不正确'
            },
            mobile: {
                validator: function (value, param) {
                    return /^(?:13\d|15\d|18\d)-?\d{5}(\d{3}|\*{3})$/.test(value);
                },
                message: '手机号码不正确'
            },
            tel: {
                validator: function (value, param) {
                    return /^(\d{3}-|\d{4}-)?(\d{8}|\d{7})?(-\d{1,6})?$/.test(value);
                },
                message: '电话号码不正确'
            },
            mobileAndTel: {
                validator: function (value, param) {
                    return /(^([0\+]\d{2,3})\d{3,4}\-\d{3,8}$)|(^([0\+]\d{2,3})\d{3,4}\d{3,8}$)|(^([0\+]\d{2,3}){0,1}13\d{9}$)|(^\d{3,4}\d{3,8}$)|(^\d{3,4}\-\d{3,8}$)/.test(value);
                },
                message: '请正确输入电话号码'
            },
            number: {
                validator: function (value, param) {
                    return /^[0-9]+.?[0-9]*$/.test(value);
                },
                message: '请输入数字'
            },
            money: {
                validator: function (value, param) {
                    return (/^(([1-9]\d*)|\d)(\.\d{1,2})?$/).test(value);
                },
                message: '请输入正确的金额'

            },
            mone: {
                validator: function (value, param) {
                    return (/^(([1-9]\d*)|\d)(\.\d{1,2})?$/).test(value);
                },
                message: '请输入整数或小数'

            },
            integer: {
                validator: function (value, param) {
                    return /^[+]?[1-9]\d*$/.test(value);
                },
                message: '请输入最小为1的整数'
            },
            integ: {
                validator: function (value, param) {
                    return /^[+]?[0-9]\d*$/.test(value);
                },
                message: '请输入整数'
            },
            range: {
                validator: function (value, param) {
                    if (/^[1-9]\d*$/.test(value)) {
                        return value >= param[0] && value <= param[1]
                    } else {
                        return false;
                    }
                },
                message: '输入的数字在{0}到{1}之间'
            },
            minLength: {
                validator: function (value, param) {
                    return value.length >= param[0]
                },
                message: '至少输入{0}个字'
            },
            maxLength: {
                validator: function (value, param) {
                    return value.length <= param[0]
                },
                message: '最多{0}个字'
            },
            //select即选择框的验证
            selectValid: {
                validator: function (value, param) {
                    if (value == param[0]) {
                        return false;
                    } else {
                        return true;
                    }
                },
                message: '请选择'
            },
            idCode: {
                validator: function (value, param) {
                    return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value);
                },
                message: '请输入正确的身份证号'
            },
            loginName: {
                validator: function (value, param) {
                    return /^[\u0391-\uFFE5\w]+$/.test(value);
                },
                message: '登录名称只允许汉字、英文字母、数字及下划线。'
            },
            equalTo: {
                validator: function (value, param) {
                    return value == $(param[0]).val();
                },
                message: '两次输入的字符不一至'
            },
            englishOrNum: {// 只能输入英文和数字
                validator: function (value) {
                    return /^[a-zA-Z0-9_ ]{1,}$/.test(value);
                },
                message: '请输入英文、数字、下划线或者空格'
            },
            xiaoshu: {
                validator: function (value) {
                    return /^(([1-9]+)|([0-9]+\.[0-9]{1,2}))$/.test(value);
                },
                message: '最多保留两位小数!'
            },
            ddPrice: {
                validator: function (value, param) {
                    if (/^[1-9]\d*$/.test(value)) {
                        return value >= param[0] && value <= param[1];
                    } else {
                        return false;
                    }
                },
                message: '请输入1到100之间正整数'
            },
            jretailUpperLimit: {
                validator: function (value, param) {
                    if (/^[0-9]+([.]{1}[0-9]{1,2})?$/.test(value)) {
                        return parseFloat(value) > parseFloat(param[0]) && parseFloat(value) <= parseFloat(param[1]);
                    } else {
                        return false;
                    }
                },
                message: '请输入0到100之间的最多俩位小数的数字'
            },
            rateCheck: {
                validator: function (value, param) {
                    if (/^[0-9]+([.]{1}[0-9]{1,2})?$/.test(value)) {
                        return parseFloat(value) > parseFloat(param[0]) && parseFloat(value) <= parseFloat(param[1]);
                    } else {
                        return false;
                    }
                },
                message: '请输入0到1000之间的最多俩位小数的数字'
            }
        });

    </script>
</body>

0 0