Javascript Trigger Docs – Submit Validation Question
-
I know there’s a few triggers as seen here:
http://contactform7.com/2012/09/24/contact-form-7-33/#more-2598
Is there any documentation in the FAQ as to what each does? I’m specifically curious as to how/if I can leverage
submit.wpcf7
for this scenario.—–
My scenario is that I want to validate specific upload field via javascript before the form submits. My issue is that I can’t combine the normal ajax submissions validation state with my own validation, it’s either one or the other.
I’m currently using something like this:
$( '#my-submit' ).click( function( e ) { validateFile(); if( $( '#nn-file' ).hasClass( 'file-not-valid' ) ) { e.preventDefault(); return false; } } );
Simple and straightforward, runs function that validates a file and sets a class. I have further logic which sets a message similar to a WPCF7 but it’s not needed for this question. The issue is that it doesn’t combine with the ajax validation because it cuts off / returns early. So in the end the user either see overall validation or my specific validation.
I also noticed there’s the custom validation hooks ( http://contactform7.com/2015/03/28/custom-validation/ ) which is pretty cool but I don’t think it will work in this case because the file would need to be uploaded before I can validate anything it in PHP ( as far as I know, $_FILES array wouldn’t be populated quite yet ).
Just as a little bit more information – I’m testing the width / height of the image to ensure it meets the standards required.
Is there anything I can do to combine both my custom JS validation with the AJAX validation to return specific errors for specific fields?
- The topic ‘Javascript Trigger Docs – Submit Validation Question’ is closed to new replies.