Search the Community
Showing results for tags 'Date'.
The search index is currently processing. Current results may not be complete.
-
Hello Caspio Family, Unfortunately, Caspio doesn't have a feature that would allow validating the date before the Submission Form. The only way I found using Caspio standard features is to show a warning message when the date doesn't fit the condition (e.g. when the date should not be prior to today). You can do that with the help of rules. I will show you an example with two dates 'Start Date' and 'End Date' with conditions: the Start Date shouldn't be prior to today and the End Date should not equal or be before the Start Date. 1) Add 2 HTML blocks beneath each Date field and add a section to each HTML block 2) Inside HTML blocks we need to add some warning message in case the condition is not met 3) Create 2 Rules as on screenshots That solution will show our warning messages, but won't prevent form submission if a user disregards the warning. But if it is necessary to let users submit only correct dates, you can use the second solution with JavaScript: 1. Insert Header&Footer, HTML block 1, HTML block 2, and place them below our Date fields. No need to add extra sections. 2. In the Header enable 'Source' and paste the code:<script>document.addEventListener("BeforeFormSubmit", function (event) {startDate = document.querySelector("#InsertRecordDateStart").value;endDate = document.querySelector("#InsertRecordDateEnd").value;warn1 = document.querySelector("#warning1");warn2 = document.querySelector("#warning2");var today = new Date();var dd = String(today.getDate()).padStart(2, '0');var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!var yyyy = today.getFullYear();today = mm + '/' + dd + '/' + yyyy;if (startDate < today) {event.preventDefault();warn1.style.display = 'block'} else {warn1.style.display = 'none'}if (endDate <= startDate) {event.preventDefault();warn2.style.display = 'block'} else {warn2.style.display = 'none'}});</script> 3. In the HTML block 1 enable 'Source' and paste:<span id="warning1" style="color:#FF0000;display:none;">Start date cannot be in the past or empty</span> 4. In the HTML block 2 enable 'Source' and paste:<span id="warning2" style="color:#FF0000;display:none;">End date cannot be prior or same as Start date or empty</span> 5. Make sure your datafield 1 and datafield 2 are called 'DateStart' and 'DateEnd' respectively or in the JavaScript added to the Header you need to replace in the linesstartDate = document.querySelector("#InsertRecordDateStart").value;endDate = document.querySelector("#InsertRecordDateEnd").value;to the name of the fields you have. You can test to see how it works on my DataPages: 1st solution with Rules 2nd solution with JS
- 6 replies
-
- js
- javascript
-
(and 3 more)
Tagged with:
-
I have a workflow that will only let a user enter a date ranging from 7 days before the current date. Obviously a calendar pop up wont work since I can't disable other choices there. So I created a task that will update the table daily and put the necessary choices that I have. This way its dynamic and I don't need to change it everyday. Here is the Task: The task above will run every day and will first delete all the existing records within the table and replace it with the new set of 7 days. An example would be. Today is May 10 here in my location and that will give me May 3 - May 10 of range. Table: DataPage: Note: You can also edit this workflow where when a date is selected that option will be removed from the Table. That will use a trigger that will delete a date when it sees it after a user submission.
-
Hi, I have a date field in my submission form and I want to prevent the user from selecting a date that is not within a specified range of dates. Like for example, I only want the user to input dates that are within 12/01/2022 to 12/12/2022. Any dates that are not within that period will not be allowed.
- 1 reply
-
- date
- submission form
-
(and 2 more)
Tagged with:
-
I want to be able to limit inline edits/inserts on a datapage. I'm trying to limit a date to dates that are after 1 week ago. Is there a way I can do this?
- 1 reply
-
- inline
- inline edit
-
(and 4 more)
Tagged with:
-
I want a calculated field formula that can return the date in MM/DD/YYYY format. How can I get this?
- 1 reply
-
- calculate
- calculated field
-
(and 1 more)
Tagged with: