Last active
March 4, 2020 20:02
-
-
Save New0/6c471fc489ed00f657b8160c18e23d8c to your computer and use it in GitHub Desktop.
For Caldera Forms, check filetype errors and prevent page navigation if detected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: CF File Error On Page Nav | |
* Description: Check if a File Type error is displayed during Next page button click and prevents navigation if found. | |
* Author: New0 | |
*/ | |
// Add jQuery to document footer | |
add_action('wp_footer', function(){ | |
?> | |
<script> | |
jQuery( '.cf-page-btn-next' ).click(function() { | |
if( jQuery('.cf2-file-error').length > 0){ | |
jQuery([document.documentElement, document.body]).animate({ | |
scrollTop: jQuery(".cf2-file-error:contains('This file type is not allowed.')").offset().top | |
}, 2000); | |
} | |
}); | |
</script> | |
<?php | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment