Conditional logic in combination with date value

Home Forums Quform WordPress Conditional logic in combination with date value

This topic is: resolved
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #33789
    klurth
    Participant

    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,
    Thomas

    #33791
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #33792
    klurth
    Participant

    Hey 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,
    Thomas

    #33797
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #33799
    klurth
    Participant

    Hey 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,
    Thomas

    #33800
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #33810
    klurth
    Participant

    Many 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,
    Thomas

    #33814
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #33816
    klurth
    Participant

    Hi 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,
    Thomas

    #33821
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #33870
    klurth
    Participant

    Hey Ally,

    thank you! You can mark this thread as solved.

    Best regards,
    Thomas

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy