Skip to content

Instantly share code, notes, and snippets.

@New0
Last active March 4, 2020 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save New0/6c471fc489ed00f657b8160c18e23d8c to your computer and use it in GitHub Desktop.
Save New0/6c471fc489ed00f657b8160c18e23d8c to your computer and use it in GitHub Desktop.
For Caldera Forms, check filetype errors and prevent page navigation if detected
<?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