• 自定义的验证方法Remote


        jQuery.metadata.setType("attr", "validate");
    var opts = null;
    var isValidationGroup = false;
    
    jQuery(document).ready(function () {
        InitRules();
        if (isValidationGroup) {
            if (opts != undefined || opts != null) {
                jQuery("#form1").validate(jQuery.extend(opts, {
                    onsubmit: false
                }));
            } else {
                jQuery("#form1").validate({
                    onsubmit: false
                });
            }
            InitValidationGroup();
        } else {
            if (opts != undefined || opts != null) {
                jQuery("#form1").validate(opts);
            } else {
                jQuery("#form1").validate();
            }
        }
    
    });
    
    function GetRemoteInfo1(postUrl, data) {
        var remote = {
            type: "POST",
            async: false,
            url: postUrl,
            dataType: "text",
            data: data,
            dataFilter: function(dataXML) {
                var result = new Object();
                if (dataXML == "1") {
                    result.Result = false;
                    result.Msg="已存在,另换一个试试。";
                    return result;
                }
                else {
                    result.Result =true;
                    return result;
                }
            }
        };
        return remote;
    }
    
    function InitRules() {
        var dataCode = {
            username: function () {
                return $("#txtUserName").val();
            },
            key:function(){
                return "CheckSysAdminName";
            }
        };
        var remoteCode = GetRemoteInfo1('/Service/sysHandle.ashx', dataCode);
    
        opts = {
            rules: {
                txtUserName: {
                    required: true,
                    remote:remoteCode
                },
                txtPass:{
                    required: true,
                    minlength: 6
                },
                txtAgainPass:{
                    required: true,
                    equalTo: "#txtPass"
                },
                txtName:{
                    required: true
                }
            },
            messages: {
                txtUserName: {
                    required: "请输入账号。"
                },
                txtPass:{
                    required: "请输入密码。",
                    minlength: "至少输入6位的密码。"
                },
                txtAgainPass:{
                    required: "请输入确认密码。",
                    equalTo: "密码不一致。"
                },
                txtName:{
                    required:"请输入姓名。"
                }
            }
            , success: function (label) {
                label.html(" ").attr("class", "success").siblings("label").remove();
            },
            errorPlacement: function (error, element) {
                $(element).next("span").find(".success").remove();
                error.appendTo(element.next("span"));
            }
        }
    }
  • 相关阅读:
    EXCEL中统计个数问题
    Boot Windows XP from a USB flash drive
    转:用VHD文件将Windows 7安装到虚拟磁盘
    CPU性能排名
    活动目录维护
    IE7占用CPU资源非常高
    不得不看:Windows Data Protection
    硬盘模式为UDMA 2.
    转载:NC6400安装Win7系统驱动列表及注意事项
    HP笔记本电池
  • 原文地址:https://www.cnblogs.com/hougelou/p/3245464.html
Copyright © 2020-2023  润新知