• Resolved nicowob123

    (@nicowob123)


    Hi,

    is it possible to fill an “age” number field based on the birthdate i get using date picker ?

    thank you in advance for your help !

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @nicowob123

    I hope you’re well today!

    Currently it’s not possible out of the box but it may be doable with additional custom code.

    I’d rather not make promises at this point but I have asked our developers to look into it and see if they can come up with some solution.

    I’d appreciate some patience as they are dealing with a lot of complex tasks on daily basis and their response time may be a bit long but we’ll update you here as soon as we get to know more.

    Best regards,
    Adam

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @nicowob123 ,

    Please try this code snippet as MU plugin (as described here https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins )

    
    <?php
    add_action( 'wp_footer', 'wpmudev_datepicker_calculate_date', 9999 );
    function wpmudev_datepicker_calculate_date() {
    	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');
    		},100);
    
    		$(document).on('after.load.forminator', function(e, form_id) {
    			if($('#forminator-module-2910').length) {
    				$('#date-1 .forminator-datepicker').on('change', function() {
    					var enteredDate = $(this).val();
    					var years = new Date(new Date() - new Date(enteredDate)).getFullYear() - 1970;
    					$('#number-1 input').val(years).trigger('change');
    				});
    			}
    		});
    	});
    	</script>
    	<?php
    }

    Make sure to change the form ID from 2910 to your form’s ID here → $('#forminator-module-2910')

    and change #number-1 input to the ID of you field.

    kind regards,
    Kasia

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @nicowob123 ,

    We haven’t heard from you for a while now, so it looks like you don’t need our assistance anymore.

    Feel free to re-open this ticket if needed.

    Kind regards
    Kasia

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Age Calculator’ is closed to new replies.