-
nikifoxAsked on May 28, 2020 at 5:28 PM
Hello,
I would like to set the custom default date for a Date Picker question to be the first of the current month, but I only see an option to set it to a fixed date.
How can I set it so that the default date automatically updates to reflect the current month every month? Ex: next month the default date would change to 2020-5-1.
Thank you!
-
Kevin Support Team LeadReplied on May 28, 2020 at 9:06 PM
This is not currently possible to do with the current date picker settings or the available widgets, I have been performing some tests and was unable to find a workaround for this, we may however open a feature request for this, although we cannot provide an ETA, we would keep you updated via this ticket, kindly confirm so we can proceed with the request.
-
Kevin Support Team LeadReplied on May 28, 2020 at 9:41 PM
I found a workaround using the Date Picker and the Substring widgets, here are the steps:
- First add the following elements to your form:
1. Date Picker widget, you will find it under the widgets tab.
2. Substring widget.
3. A short text entry field.
- The date picker widget must be configured like this:
- The Substring widget must be configured like this:
On this widget you will also use the field ID, you may refer to this guide for more details about how to get this: https://www.jotform.com/help/146-How-to-Find-Field-IDs-and-Names
This widget will basically get the month and year, that's why the date format is important.
- The last step is to copy the value from the Substring widget and insert it to the short text field adding the day, here is how your condition should be configured:
The elements should be added as text, by default they are added as numeric values, but you can click on the element to add it as text.
This guide will also help you setting up this type of conditions: https://www.jotform.com/help/268-How-to-Insert-Text-or-Calculation-into-a-Field-Using-Conditional-Logic
You can test this on my form: https://form.jotform.com/201488327170959
Feel free to change the date in order to see how it's updated.
I hope this helps.
-
nikifoxReplied on June 3, 2020 at 4:00 PM
Hi Kevin,
Thank you for your solution! However there seems to be an issue with the Substring function on my form. I tried following your steps, and various other tests, but the substring does not return a value from the Date Picker widget. I used the ID from the "Field ID" section of the Date Picker. Also, the number in the calculation (0, 1) will not save as text- if I click them to make them grey and save, the next time I open the calculations they are black again.
Please advise on how to get Substring to work, thanks!
-
David JotForm Support ManagerReplied on June 3, 2020 at 9:28 PM
Hi, the Substring widget requires using the field ID. You are using the Card Forms layout, and in this layout, the field does not have an ID.
You can solve this by:
1) Switching the layout to the Classic one: https://www.jotform.com/help/493-How-to-Change-the-Form-Layout
2) Getting the ID of the Date Picker widget:
3) Put the ID in the Substring widget.
4) Switch back to Cards layout.
Result: https://form.jotform.com/201547938650966
Let us know if you need more help.
-
nikifoxReplied on June 4, 2020 at 4:23 PM
Thank you for the Field ID explanation. I would like to hide the Current Date but use substring from it to populate the First Day of the Month, however when I hide Current Date the substrings do not return a value.
Is there a workaround for this?
Thanks!
-
David JotForm Support ManagerReplied on June 4, 2020 at 7:01 PM
Hi, I am afraid that there is no other workaround in the Card layout, the widget needs to show up, so the value can be passed to the substring widget.
If you try the Classic layout, the widget can be hidden with CSS code:
#id_267{
visibility: hidden;
}
So, the value will still pass. Unfortunately, the Card layout does not allow CSS code injection.