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;
    }
原文地址:https://www.cnblogs.com/dabaopku/p/2531480.html