0

I have a MailChimp sign up form on a ASPX hosted site - the traditional form action does not work, so i've had to make the form submit via jQuery as per code below.

Issue is... the validation is ignored now and the form submits even if the required fields are left empty... The HTML5 validation throws an error - but jQuery then submits the form and moves the user away from the form...

How can I force jQuery to wait for the HTML5 validation to be confirmed as correct before submitting?

Form submit button code is:

<input id="mc-embedded-subscribe" name="subscribe" type="submit" value="Subscribe" class="button" onClick=this.form.action='https://accountname.us2.list-manage.com/subscribe/post?u=abc&amp;id=123';this.form.submit(); /></div>

Field that needs to be completed is:

<input id="mce-EMAIL" name="EMAIL" type="email" value="" class="required email" required  />        

Please note to make the form work on ASPX - I've had to remove all "form" tag elements - so not sure the traditional jQuery validate approach will work... See > https://mailchimp.com/help/troubleshooting-the-embedded-signup-form/#The_embedded_form_code_doesn%27t_work_with_ASP.NET.

Form code is:

<form id="formID">
        <div class="mc-field-group">
            <label for="mce-EMAIL">Email Address <span class="asterisk">*</span> </label> <input class="required email" id="mce-EMAIL" name="EMAIL" required="" type="email" value="" required /></div>


        <div class="clear SubmitBtnWrapper">
            <input class="button" id="mc-embedded-subscribe" name="subscribe" onclick="this.form.action='https://brandname.us2.list-manage.com/subscribe/post?u=123&amp;id=abc';this.form.submit();" type="submit" value="Subscribe" /></div>

    </form>
dubbs
  • 1,167
  • 2
  • 13
  • 34
  • use Jquery validator and use $( "#formname" ).validate(); before submitting the data https://jqueryvalidation.org/?name&email&url&comment – Shubham Feb 28 '20 at 10:13
  • Thanks - not sure this will work though as the form has no
    elements as per > https://mailchimp.com/help/troubleshooting-the-embedded-signup-form/#The_embedded_form_code_doesn%27t_work_with_ASP.NET.
    – dubbs Feb 28 '20 at 10:18
  • in that case you can use $('#elementid).valid(); to validate the input field before submitting. – Shubham Feb 28 '20 at 10:31
  • OK, I was going down that route but i could not seem to get it to work - any suggestions on the approach to use – dubbs Feb 28 '20 at 10:33

0 Answers0