日期:2014-05-17  浏览次数:20834 次

急!!!jquery如何调用的?

JScript code

       $(function(){
            $("input[name=loginName]").attr("minlength", "2");
            $("input[name=loginName]").attr("maxlength", "64");
            $("input[name=nickname]").attr("minlength", "2");
            $("input[name=nickname]").attr("maxlength", "64");
            $("input[name=password]").attr("minlength", "2");
            $("input[name=password]").attr("maxlength", "64");
            $("input[name=password2]").attr("equalTo", "input[name=password]");
        });


它是如何调用下面的代码?

JScript code


$(function(){
 if( $("form.validate").size() > 0 ){
 // 需要验证的要在验证成功后block
 $.validator.setDefaults({
 submitHandler: function() { 
                    $.blockUI({ message: '<p style="font-size: 16px;font-weight: bold;">正在提交,请稍候...</p>' }); 
                    this.submit(); // FIXME 这行在执行时会出错,但这样可以导致提交表单,怎么正确提交表单呢?
                }
            });
            $.validator.messages = {
                required: " 请填写本字段的信息.",
                remote: "Please fix this field.",
                email: " 请填写正确的email地址.",
                url: "Please enter a valid URL.",
                date: "Please enter a valid date.",
                dateISO: "Please enter a valid date (ISO).",
                number: "Please enter a valid number.",
                digits: "Please enter only digits.",
                creditcard: "Please enter a valid credit card number.",
                equalTo: " 请填写相同的值.",
                accept: "Please enter a value with a valid extension.",
                maxlength: $.validator.format("Please enter no more than {0} characters."),
                minlength: $.validator.format(" 最小长度为 {0} 个字符."),
                rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
                range: $.validator.format("Please enter a value between {0} and {1}."),
                max: $.validator.format("Please enter a value less than or equal to {0}."),
                min: $.validator.format("Please enter a value greater than or equal to {0}.")
            }
            // class为validate的表单都要验证
            $("form.validate").validate();
        }
        // 不需要验证的提交后就block
        $("form:not(.validate)").submit(function(){
            $.blockUI({ 
                message: '<p style="font-size: 16px;font-weight: bold;">正在提交,请稍候...</p>' 
            });
        });
    
        // :not(div.content a) 在显示文章内容时出现的a,不block
        $("a:not([target]):not([href=#]):not([href^=javascript]):not([onclick]):not(a:has(img)):not(div.content a)").click(function(){
            $.blockUI({ 
                message: '<p style="font-size: 16px;font-weight: bold;">正在执行,请稍候...</p>' 
            });
        });
    });



------解决方案--------------------
JScript code
  $(function(){
            $("input[name=loginName]").attr("minlength", "2");
            $("input[name=loginName]").attr("maxlength", "64");
            $("input[name=nickname]").attr("minlength", "2");
            $("input[name=nickname]").attr("maxleng