jquery表单验证

来源:互联网 发布:没有usb虚拟打印机端口 编辑:程序博客网 时间:2024/04/27 15:53

   var validate = null;
        var opts = {
            rules: {
                LoginName: { required: true, regex: "^[a-zA-Z][a-zA-Z0-9._-]{3,20}$" }
            },
            messages: {
                LoginName: "请输入正确的登陆名"
            },
            errorLabelContainer: "#messageBox",
            wrapper: "li"
        };

        function checkForm() {
            var b = validate.checkForm();
            validate.showErrors();
            return b;
        }

        $(function () {
            validate = $("#form1").validate(opts);
        });

        function SaveUser() {
            if (!checkForm()) {
                return;
            }
            //...........
        }

 

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

原创粉丝点击