Compare date fields

By: Ita Pronk | Asked: 04/18/2022
ForumsCategory: How-toCompare date fields
Ita Pronk asked 3 years ago

Hi Guys,

I need to compare date fields, á la [https://formidableforms.com/knowledgebase/date/#kb-compare-date-fields](https://formidableforms.com/knowledgebase/date/#kb-compare-date-fields)

Goal is: if there is 0 days difference between the 2 dates, then the form may be shown.

I think I have done it correctly, but I get no calculation result between the 2 dates:

[https://evaluatie.webbureauifra.nl/wp-content/uploads/2022/04/Schermafbeelding-2022-04-18-om-08.37.08.png](https://evaluatie.webbureauifra.nl/wp-content/uploads/2022/04/Schermafbeelding-2022-04-18-om-08.37.08.png)

I have 2022 as my theme and have removed all irrelevant plugins.

Could it be that a depreciated part of Jquery is used within Formidable Forms Pro?

[https://evaluatie.webbureauifra.nl/wp-content/uploads/2022/04/WhatsApp-Image-2022-04-18-at-8.36.50-AM.jpeg](https://evaluatie.webbureauifra.nl/wp-content/uploads/2022/04/WhatsApp-Image-2022-04-18-at-8.36.50-AM.jpeg)

If you want to inspect yourself: [https://evaluatie.webbureauifra.nl/evaluatieformulier/?code=sx3st&datum=20220418&training=Business%20Analyse%20Foundation%20(BAF-NL](https://evaluatie.webbureauifra.nl/evaluatieformulier/?code=sx3st&datum=20220418&training=Business%20Analyse%20Foundation%20(BAF-NL))

Thanks in advance for your help!

Ita

1 Answers
Victor Font answered 3 years ago

There are a few things that aren't quite right with how this is setup. First, your question about deprecated jQuery. Shortcodes are PHP functions that execute on the server. They are not jQuery. Even if you did run into a deprecated jQuery function, you would see an error in the browser console.

Second, you placed the date_calc shortcode in the CSS Layout Classes area. This field only works correctly with CSS class names. Shortcodes need to placed in the default value field. Try moving it there and test again.

Last, the jQuery error you see has nothing to do with the date field. If you examine the error in the browser's console, the jQuery that is producing the error is:

jQuery(document).ready(function($){

$('#code66').change(function(){

var sourceField = $('#code66').val();

$('#naam65').val(sourceField);

$('#naam65').trigger({ type:'change', originalEvent:'custom' });

});

});

I don't know how you inserted this script, but the opening script tag is at the end of the previous input field. There is also a lot of white space after the script tag. This white space is either confusing wautop or the browser. You need to insert the jQuery correctly without white space after the tags.

Whever I run into problems with jQuery, I directly inject it into the page header with the wp_head() hook. I also use PHP_EOL at the beginning and end of the injected code so the code all appears within its own block. It solves a lot of problems.

Ita Pronk replied 3 years ago

Hi Victor, thank you very much for your reaction!

On point 1: OK, it was a suggestion I thought I saw in the inspector. So it has nothing to do with it at all.

On point 2: Yes, I see it! How silly of me! And I kept overlooking it (I've been 'debugging' for almost 2 days)!!!

On point 3: This a snippet that I found on the Formidable form: https://formidableforms.com/knowledgebase/lookup/#kb-copy-value-to-a-lookup-field
I wanted to use this to try to have data from the event in question loaded via a Lookup field via another parameter ('sku'). I'm going to take a closer look at this.

Have a nice day and thanks again for your help!

Ita

Ita Pronk replied 3 years ago

Btw: the last script was added in the after-fields part of the settings of the form.

Ita Pronk replied 3 years ago

Btw2: </p><br />
Do you know if there is a difference between

**[date_calc id=69 compare=67 format=days] **
where 69 is start-date and 67 is end-date

and

**[start-date]-[end-date]** ?

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right