jQuery Validate 应用

验证输入的jQuery插件

http://docs.jquery.com/Plugins/Validation/validate#options

 

$(document).ready(function () {
        $("form").validate({
            rules: {
                UserName: "required",
                Password: {
                    required: true,
                    minlength: 6
                }
            },
            success: function (label) {
                label.html(" ").addClass("validated");
            },
            showErrors: function (form, validator) {
                $(".error").removeClass("validated");
                this.defaultShowErrors();
            }
        });
    });
label.validated {
        background: url('ok.png') no-repeat;
        width: 32px;
        height: 32px;
        margin: 0;
    }

posted on 2012-06-02 01:22  大宝pku  阅读(182)  评论(0编辑  收藏  举报

导航