Skip to content

Instantly share code, notes, and snippets.

@wpmudev-sls
Last active April 25, 2025 15:50
Show Gist options
  • Save wpmudev-sls/8ca7f7f25406e62c06a8e8cf756d4b91 to your computer and use it in GitHub Desktop.
Save wpmudev-sls/8ca7f7f25406e62c06a8e8cf756d4b91 to your computer and use it in GitHub Desktop.
[Forminator Pro] - Fix date offset validation issue with page reload method
<?php
/**
* Plugin Name: [Forminator Pro] Fix date offset validation issue with page reload method
* Description: Fix date offset validation issue with page reload method.
* Author: Prashant @ WPMUDEV
* Task: SLS-7000
* Author URI: https://premium.wpmudev.org
* License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
add_action(
'wp_footer',
function () {
global $post;
if ( is_a( $post, 'WP_Post' ) && ! has_shortcode( $post->post_content, 'forminator_form' ) ) {
return;
}
?>
<script type="text/javascript">
jQuery(document).ready(function($){
setTimeout(function() {
$('.forminator-custom-form').trigger('after.load.forminator');
},500);
$(document).on('after.load.forminator', function(e, form_id) {
if ( 'forminator-module-71' === e.target.id ) { // Please change the form ID.
$.validator.addMethod("date_valid", function (value, element) {
var start_date = $(element).attr('data-start-date').split('-').join('/');
start_date = Date.parse( start_date );
value = value.split('.').reverse().join('/');
value = Date.parse( value );
if ( value && value < start_date ) {
return false;
}
return true;
},"Bitte gib ein gültiges Datum ein.");
$( "#date-1 input" ).attr( "date_valid", "date_valid" );
}
});
});
</script>
<?php
},
9999
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment