Home › Forums › Quform WordPress › Conditional logic in combination with date value
- This topic has 10 replies, 2 voices, and was last updated 2 years, 10 months ago by klurth.
- AuthorPosts
- December 7, 2021 at 4:13 pm #33789klurthParticipant
Hey there,
I found several forum entries for conditional logic in combination with date values like an age validator. Unfortunately I am not able to get started with my “challenge” 🙂
I have the following situation. I want the user of the form to enter a date in the past. If this date is more than e. g. 6 months ago, I want to display html field X. If this date is less than e. g. 6 months ago, I want to display html field Y. I know how to control the html fields with conditional logic in certain date ranges. But I cannot figure out how to set the dynamic range (Today minus 6 months or sth. similar).
Your help is much appreciated.
Thanks,
ThomasDecember 8, 2021 at 11:21 am #33791AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 8, 2021 at 12:25 pm #33792klurthParticipantHey Ally,
wow! Thanks a lot for the quick response and the solution. Works like a charm!
Advanced question… Is it possible to adjust the code to count days instead of months? I tried some changes, but I’m a newbie to javascript 🙁
And I’d like to buy you a coffee for your awesome work. Do you have a donation link?
Regards,
ThomasDecember 9, 2021 at 10:01 am #33797AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 9, 2021 at 11:14 pm #33799klurthParticipantHey Ally,
once again thanks a lot! It also works perfectly. May I disturb you one more time? It’s really the last time. I promise 🙂
How can I add a specific number of days to a date? For example: date is entered in field 1_3, let’s say 09.12.2021. And I want to add 21 days to show in another field (1_8) to output 30.12.2021 and add 28 days to output 06.01.2022 in field 1_9.
Thanks again and enjoy your coffee 😉
Regards,
ThomasDecember 10, 2021 at 11:30 am #33800AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 14, 2021 at 9:05 am #33810klurthParticipantMany thanks again, Ally!
OK, will do 🙂
Is it possible to validate a date field, check the date format immediately and print out an error message, if the format is wrong? For example: I need to have the format dd.mm.yyyy but the user inputs dd.mm.yy. Error message could be sth. like this: “Please enter the correct date format” Or is it even possible to change the input into the right format automatically?
Regards,
ThomasDecember 14, 2021 at 9:46 am #33814AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
December 14, 2021 at 11:17 am #33816klurthParticipantHi Ally,
yes, it is a date field. I’m using conditional logic in combination with the date field and the javascript calculations above. To be more specific: If the days between field 1_3 and the hidden field 1_4 are less then 28 field 1_9 ($datePlus28) should be displayed. In this case it is not necessary to submit the form.
But the field 1_9 is not displayed if the the date format in field 1_3 is dd.mm.yy and not dd.mm.yyyyy.
So my first Idea was to check if the date format is valid and notificate the user.
Alternatively I wondered to switch off the input option and only use the date picker. That would be fine for me as well. While using the date picker it works as expected.
Regards,
ThomasDecember 15, 2021 at 9:26 am #33821AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
January 6, 2022 at 6:35 pm #33870klurthParticipantHey Ally,
thank you! You can mark this thread as solved.
Best regards,
Thomas - AuthorPosts
- You must be logged in to reply to this topic.