0

I have an Ajax-Loader (".ajax-loader") that is only visible if my (contact 7) form checks the form for errors. In this moment i want to remove the class="submit-active" from the submit button:

 jQuery(document).ready(function($) {
    $('.wpcf7-form .wpcf7-submit').addClass("submit-active");

    $(".wpcf7-submit").click(function() {
        if ($('.wpcf7-form .ajax-loader').css('visibility') == 'hidden') {
            $('.wpcf7-form .wpcf7-submit').removeClass("submit-active");
        }
    });
});

This works. The only problem now is: How di I add the class "submit-active" to the submit button again after ".ajax-loader" is hidden again?

herrfischer
  • 1,768
  • 2
  • 22
  • 35
  • 1
    how/when is the `ajax-loader` hidden? Is there an event? – M B Aug 12 '16 at 15:44
  • I found nothing about an event. – herrfischer Aug 12 '16 at 15:47
  • When are you removing this class? You left out the part of your code that would hide the `ajax-loader` and put back the `submit-active` class – M B Aug 12 '16 at 15:48
  • When I click on the button I remove the class "submit-active". Then the form checks the fields. After that I want to add the class "submit-active" again. The more I think about it the more I think this is not possible because I need some kind of event that the script does. – herrfischer Aug 12 '16 at 15:51
  • 1
    set a flag against submit – Rashid Javed Aug 12 '16 at 15:51
  • 1
    How does the form check? Is there a function? an ajax call? – M B Aug 12 '16 at 15:56
  • Just found this: http://stackoverflow.com/questions/27798264/contact-form-7-ajax-callback. Think I have to try with theese. – herrfischer Aug 12 '16 at 16:09

0 Answers0