javascript - MailChimp JS Validation Isn't Working -
i using 1 of mailchimp's embedded forms, copied wordpress popup builder. issue js in mailchimp's form causing error, validation of form doesn't work. here error:
uncaught typeerror: cannot read property 'replace' of undefined // error occurs in file: mc-validate.js:198
and here full form code:
<!-- 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 own mailchimp form style overrides in site stylesheet or in style block. recommend moving block , preceding css link head of 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 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 in , expect things - not remove 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-->
edit: plugin i'm using popup indeed smart popup
in our case, following code in hosted file mc-validate.js
responsible:
/** * grab list subscribe url form action , make work ajax post. */ getajaxsubmiturl: function() { var url = $("form#mc-embedded-subscribe-form").attr("action"); url = url.replace("/post?u=", "/post-json?u="); url += "&c=?"; return url; },
the line starts var url = …
looking form
id mc-embedded-subscribe-form
. if form id missing page, script fails. in op's code looks form exists, i'm not 100% sure why code failing on op's page. in our page, had changed form's id, , cause of error.
Comments
Post a Comment