简体   繁体   English

'dijit.form.Form'为null或不是IE中的对象,并且正则表达式不起作用

[英]'dijit.form.Form' is null or not an object in IE and regex doesn't work

I am getting an error in IE and also the regular expression part of dojo.form.ValidationTextBox fails no matter what in any browser. 我在IE中遇到错误,无论在任何浏览器中,dojo.form.ValidationTextBox的正则表达式部分都会失败。 What am I doing wrong here? 我在这里做错了什么? I am loading the library through Google API. 我正在通过Google API加载库。 Below is my code, if you can help that would be awesome. 下面是我的代码,如果您可以帮助的话,那就太好了。 I am wondering if this is a bug with the library itself. 我想知道这是否是库本身的错误。

if (typeof(djConfig)=='undefined') {
    djConfig = {
        isDebug: false,
        parseOnLoad: true
    };
}

if (document.location.protocol=='https:') {
    djConfig.modulePaths={
        "dojo":"https://ajax.googleapis.com/ajax/libs/dojo/1.5.0/dojo",
        "dijit":"https://ajax.googleapis.com/ajax/libs/dojo/1.5.0/dijit",
        "dojox":"https://ajax.googleapis.com/ajax/libs/dojo/1.5.0/dojox"
    };
}

google.setOnLoadCallback(function() {
    dojo.require("dijit.form.Form");
    dojo.require("dijit.form.ValidationTextBox");
    dojo.require("dojox.validate.regexp");

    dojo.addOnLoad(function() {
        var newsletterForm = new dijit.form.Form({
            action: '/newsletter.cfm',
            method: 'post',
            target: '_blank'
        }, dojo.byId('newsletter-form'));

        var newsletterEmail = new dijit.form.ValidationTextBox({
            invalidMessage: 'Please double-check your email address',
            promptMessage: 'Enter your email address', 
            regExp: '^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$',
            required: true,
            tooltipPosition: 'below'
        }, dojo.byId('newsletter-email'));
    });
});

google.load('dojo', '1.5');

Here is the answer guys. 这是答案。 Apparently Dojo developers are not too keen on usage for Internet Explorer. 显然,Dojo开发人员对Internet Explorer的使用不太热衷。 You must add setTimeout and create an init function inside there, at least that is what I did. 您必须添加setTimeout并在其中创建一个init函数,至少那是我所做的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM