Gar*_*944 5 javascript validation wordpress jquery mailchimp
我正在使用MailChimp的一种嵌入式表单,复制到wordpress弹出窗口生成器中。问题是MailChimp表单中的JS导致错误,因此表单验证不起作用。这是错误:
Uncaught TypeError: Cannot read property 'replace' of undefined
// This error occurs in the file: mc-validate.js:198
Run Code Online (Sandbox Code Playgroud)
这是完整的表单代码:
<!-- Begin MailChimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/classic-081711.css" rel="stylesheet" type="text/css">
<style type="text/css">
#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; width:500px;}
/* Add your own MailChimp form style overrides in your site stylesheet or in this style block.
We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>
<div id="mc_embed_signup">
<form action="" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<h2>Subscribe to our mailing list</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
<label for="mce-EMAIL">Email Address <span class="asterisk">*</span>
</label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display:none"></div>
<div class="response" id="mce-success-response" style="display:none"></div>
</div> <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;"><input type="text" name="b_c86e002570c2075b57186bd84_ee52af27a3" tabindex="-1" value=""></div>
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>
<script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script>
<script type='text/javascript'>(function($) {window.fnames = new Array(); window.ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';}(jQuery));var $mcj = jQuery.noConflict(true);</script>
<!--End mc_embed_signup-->
Run Code Online (Sandbox Code Playgroud)
编辑:我用于弹出窗口的插件是确实智能弹出窗口
在我们的例子中,托管文件中的以下代码mc-validate.js负责:
/**\n * Grab the list subscribe url from the form action and make it work for an ajax post.\n */\ngetAjaxSubmitUrl: function() {\n var url = $("form#mc-embedded-subscribe-form").attr("action");\n url = url.replace("/post?u=", "/post-json?u=");\n url += "&c=?";\n return url;\n},\nRun Code Online (Sandbox Code Playgroud)\n\n开始的行var url = \xe2\x80\xa6正在寻找FORM带有 ID 的a mc-embedded-subscribe-form。如果页面中缺少具有此 ID 的表单,则脚本将失败。在 OP 的代码中,似乎存在这种形式,所以我不能 100% 确定为什么代码在 OP 的页面上失败。在我们的页面中,我们更改了表单的 ID,这就是错误的原因。
| 归档时间: |
|
| 查看次数: |
4274 次 |
| 最近记录: |