I have a date input on a page. I pass the value entered in it to a function that will leave it alone or clear the date value in the component under certain conditions. When a user users the calendar to enter a date into the input, and clicks the validate button below, I just can’t get the function to clear the entered date value when required. The closest I could get is that “Invalid Date” appears in the input.
Thx for ideas.
Hello @musseman, thank you for your feedback.
I think there is a way to clear a variable by using a predefined function in code lines.
The predefined function is “clearVariable()
” as you can see in the documentation: Variables | Qodly Documentation
I give you an example:
The function above has one parameter that represents the date qodly source bound to the text input. I did the predefined function “clearVariable()
” to that variable if it is not empty, then I returned it as a result.
So, in the test, I select a date:
When I click on the button “Clear Date”, the input becomes empty:
Hope that this solution works on your side.
Best regards.
Thanks. Recommend clearVariable() be added to the commands section in the documentation as well.
Will try it out and report if issue, but imagine that will do the trick.
Thx.
Also-would be good if th calendar widget had a way for the user to self clear the date.
1 Like
The input is set as type date and format short date.
When the input is clicked into by the user a default Qodly calendar widget pops up
User selects a date using the widget.
The selected date appears in the input.
If the user clicks back into the input, they can only change the date with no option to just clear it. (unless i add a button, which is ok i guess.)
So 1: can their be a way for a user to self clear a dtate entered from that popup calndar widget?
2: Problem still not solved. I dont get blank input when I clear, i still get “Invalid Date” appearing in the input.
When user slects “No” form a select, the Date should be cleared:
exposed Function updatePODDOB (podtoggle:string, poddob:date)->result:date
result = podtoggle == “No” ? clearVariable(poddob) : poddob
When user selects “No” “Invalid Date” shows up in the date input.
No-code solution : you can define a Qodly source date set to an empty value and add a button with on click standard action that copies this empty date into the Qodly source linked to the date input you want to clear.