312
Views
10
Comments
Solved
[OutSystems UI] Manually input DatePicker changes input date to other date
outsystems-ui
Reactive icon
Forge asset by OutSystems

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é

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

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:

  • Define the DatePicker OnInitialized action flow
  • Execute the below-mentioned JS using the JS node in the DatePicker OnInitialized handler flow


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

RvB_Reactive_Demo.oml
2021-01-04 08-13-48
Toto
 
MVP

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.

2017-06-02 10-47-12
René van Britsem

Hi,

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,

René

RvB_Reactive_Demo.oml
2021-01-04 08-13-48
Toto
 
MVP

Hi,


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.



2017-06-02 10-47-12
René van Britsem

Hi,

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?

2021-01-04 08-13-48
Toto
 
MVP

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 :)

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

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:

  • Define the DatePicker OnInitialized action flow
  • Execute the below-mentioned JS using the JS node in the DatePicker OnInitialized handler flow


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

RvB_Reactive_Demo.oml
2017-06-02 10-47-12
René van Britsem

Thx this works!

UserImage.jpg
karthimani R

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


2022-03-21 09-36-03
Andy Smy

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;

  • it rejects input without delimiters, or
  • works as expected for unambiguous dates? e.g. 01011980 --> 01/01/1980
2023-02-03 11-00-49
Ruben Bernardo

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

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.