0

运行验证插件时,我可以看到它打印到 Firebug 中的控制台(即使我有debug: false)。

在 IE9/IE8 中运行应用程序时会失败,除非处于调试模式,即 shift+F12。在调试模式下,我可以看到它打印到 IE 控制台并且应用程序实际工作。

如何配置插件以停止打印到控制台(我假设 IE 在不处于调试模式时无法处理此问题)?或者这是验证插件中的一个错误,所以我必须自己删除这些行?

该插件正在从插件中的 defaultShowErrors 打印。

这是我的验证码示例:

function registerAccountValidation(){
    $("#registerform").validate({ 
        errorContainer: "#messageBox1",
        errorLabelContainer: "#messageBox1 ul",
        wrapper: "li", 
        debug:false,
        rules: {     
            owner_first_name: "required",
            owner_surname: "required",
            owner_email: { // compound rule 
                email: true,
                required: true,
                remote: "http://" + hostname +  "/modules/core/account/is_available.php"
            }, 
            email2: { 
                equalTo: "#email"
            },
            username: {
                required: true,
                remote: "http://" + hostname +  "/modules/core/account/is_available.php"
            },
            password: {
                required: true
            },
            password2: {
                equalTo: "#password"
            },                                
            owner_phone_number: "required",
            company_address: "required",
            zipcode: "required",
            city: "required",
            country: {
                required: true
            },
            company_name:{
                required: true,
                remote: "http://" + hostname +  "/modules/core/account/is_available.php"
            },
            company_link: {
                required: true,
                remote: "http://" + hostname +  "/modules/core/account/is_available.php",
                alpha: true
            }
        }, 
        messages: { 
            owner_first_name: {
                required: "First name is missing"
            },
            owner_surname: "Surname is missing",
            owner_email: { // compound rule 
                email: "Please specify a correct e-mail address" ,
                required: "E-mail is missing",
                remote: "E-mail address already registered"
            }, 
            email2: { 
                equalTo: "E-mail addresses must be equal"
            },
            username: {
                required: "Username is missing",
                remote: "Username is already registered"
            },
            password: {
                required: "Password is missing"
            },
            password2: {
                equalTo: "Passwords must be equal"
            },
            owner_phone_number: "Phone number is missing",
            company_address: "Address is missing",
            zipcode: "Zip code is missing",
            city: "City is missing",
            country: {
                required: "Country is missing"
            },
            company_name: {
                required: "Company name is missing",
                remote: "Company name already registered"
            },
            company_link: {
                required: "Link is missing",
                remote: "Link is already registered",
                alpha: "Must only contain a-z and A-Z and no blank space"
            }
        }
    }); 
}

更新

在插件中删除打印到控制台实际上可以解决问题。但我更喜欢以正式的方式进行,如果有的话。不想在将来更新插件时遇到问题。

4

1 回答 1

0

如果一个快速而肮脏的解决方案就足够了,您可以为没有真正的浏览器定义一个虚拟的 console.log:

if(!(window.console && window.console.log)){
    window.console = {
        log: function(){}
    };
}

如果很难找到实际问题,这至少会使错误消失。

于 2012-06-11T09:25:01.487 回答