Hi all,
I use the datepicker to enter a date. When I manually enter a date of 01011950, the date is changed to 01-11-1950.
The date format is: "DD-MM-YYYY".
How can I solve this? Does anyone have an idea?
Thanks in advance!
René
Hi René,
In addition to the previous replies, If the user input date text value format remains the same, then one of the JS solutions would be as mentioned below.
Steps to follow:
JavaScript Snippet:
setTimeout(function() { var datePickerInpt = document.getElementById($parameters.DatePickerInputId).querySelector('.input') datePickerInpt.focus(); datePickerInpt.addEventListener('change', function() { var dateIntValue = this.value; dateIntValue = dateIntValue.substr(0,2) + '-' + dateIntValue.substr(2,2) + '-' + dateIntValue.substr(4,4); this.value = dateIntValue; }); }, 100);
Demo Screen: Datums
Refer to the attached updated oml.
I hope this helps you!
Kind regards,
Benjith Sam
Hi,
You using datepicker widget right ? From Outsystems UI ? and this is Reactive app ?
If so, datepicker is readonly, how did you fill it manually ?
Can you share your oml ? So we can understand your code and question.
I am using the datepicker widget from Outsystems UI in a Reactive app.
To make sure that you can enter a date manually, I use the action: DatePickerSetEditableInput.
I have added the oml as an attachment.
Regards,
Thanks for the info, I never use date picker with manual input before :)
As for this, I have tested it, if you enter the input using - or /, it work as intended, so I suspected that in the datepicker before return selected value, there is converter, and this converter is need exact date format.
If you entered : 01-01-1950 or 01/01/1950 this is working as normal.
Thank you for looking at the problem. I just knew this worked. The point is that I can enter a date without separators. I would like to know how I can do that.
I understand that it is possible to use a Javascript to ensure that the separators (-) are entered. Then it should be fine. My question is, does anyone have an example of this? And how exactly do I apply that?
I got a rough idea.
You need to cloned the Outsystems UI, and change the behavior of the datepicker on the cloned module.
Like I said, it seems the date conversion that is the problem, as by default is not accepting ddmmyyyy as input, but dd/mm/yyyy or dd-mm-yyyy is accepted. So need to find this on the cloned module and add logic to do this.
I'll try this, but I'll do this on the spare time, so I cannot guarantee when :)
Thx this works!
how to make date to be changed dynamically after entering the date manually in date picker. The issue is in date picker the entered date is updated only after closing and opening the date picker
This needs re-opening as it is not solved - adding code to work around a bug is not a solution, it's a workaround. After all, OutSystems is meant to generate the code, not us!
When will this be fixed so that, either;
Had the same problem and I came to the conclusion that the "problem" is in the provider itself and not in the DatePicker.
It is just the way the parser was built considering the regex patterns defined.
Maybe masking the input before triggering the OnChange hook, could work. idk