- 🇮🇳India shahin-raza Mumbai
Any solution for this issue? I am also facing the date caching issue in webform for anonymous users, today's date is showing one day late.
- 🇺🇸United States jrockowitz Brooklyn, NY
Your best work-around may be to set the default date using JavaScript.
- 🇷🇺Russia alex malik
I tried using Custom JavaScript, it works. The date changed immediately without clearing the cache. Here is my code
document.addEventListener('DOMContentLoaded', function () { // Find date fields by their ID var dateField1 = document.getElementById('edit-your-date-field-id-3days'); // For +3 days var dateField2 = document.getElementById('edit-your-date-field-id-21days'); // For +21 days // Get current date var today = new Date(); // Set date for +3 days today.setDate(today.getDate() + 3); dateField1.value = today.toISOString().split('T')[0]; // Format YYYY-MM-DD // Set date for +21 days today.setDate(new Date().getDate() + 21); dateField2.value = today.toISOString().split('T')[0]; // Format YYYY-MM-DD });
How to Use:
1. Replace the Identifiers:- Change 'edit-your-date-field-id-3days' and 'edit-your-date-field-id-21days' to the actual IDs of your date fields.
2. Insert the Code:
Add this code in the custom JavaScript section of your web form settings. /admin/structure/webform/manage/webform-id/settings/assets
3. Save Changes and verify the results on the form page.