Re-Initiate script

Home Forums Jquery Validation for Contact Form 7 Re-Initiate script

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5247
    Rick
    Guest

    AY!

    I’m loading a form (Contact Form 7) onto a page using AJAX, which broke the form’s AJAX. However, by using Contact Form 7’s .wpcf7InitForm(); function, I was able to get it to work again with the validation, but not the jQuery Validation plugin’s validation.

    Problem – it appears that the Validation plugin no longer works on this form, and my only guess is that it may need to be initiated again?

    Ideas?

    #5248
    Dinesh
    Keymaster

    Hi Rick,

    Ya, you are right loading the form via ajax need the re-initiation.

    Since we don’t have proper function for this, you can use this code to

    // VALIDATION CODES
    jQuery(document).ready(function(){	
    	jQuery('.wpcf7-validates-as-required').addClass('required');
    	jQuery('.wpcf7-email').addClass('email');
    	
    	jQuery('form.wpcf7-form').each(function(){
    		jQuery(this).validate();
    		jQuery(this).addClass(jvcf7_invalid_field_design);
    		jQuery(this).addClass(jvcf7_show_label_error);
    	});	
    });

    Hope this helps.

    Thanks

    #5251
    Rick
    Guest

    Hm. This didn’t manage to work. I corrected the last two addClass lines with quotes. It looked like it WORKED but it wasn’t reading the settings I saved in the plugin.

    I’ve worked around with the normal validation – but if we can figure out how to get this one to work (for future and other people) then that’d be awesome.

    #5252
    Dinesh
    Keymaster

    Hi Rick,

    Any chance you can send me your site url where you have setup the form to load via ajax ?

    Thanks

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Re-Initiate script’ is closed to new replies.