Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to translate the md-datepickers "Invalid Date" message?

like the topic says: in my project i have a md-datepicker, which in some cases (which are intended) shows "Invalid Date". Is there any possibility to translate or change this text?

like image 901
Philipp Kohlmann Avatar asked Dec 02 '25 15:12

Philipp Kohlmann


1 Answers

Yes.

Actually, I'd got the same problem and "Invalid Date" should not be good at all. I thought it should be blank.

In my project, it happened when I enabled "md-open-on-focus" and I click on the input (not on icon or caret).

In addition, I was using Moment.js with the following configuration:

    $mdDateLocaleProvider.formatDate = function (date)
    {
        return moment(date).format('DD/MM/YYYY');
    };

As you can see, an invalid date like null or empty was formated and then returned.

Then, I've solved it by replacing it to this:

    $mdDateLocaleProvider.formatDate = function (date)
    {
        var tempDate = moment(date);
        return (tempDate.isValid() ? tempDate.format('DD/MM/YYYY') : '');
    };
like image 173
Marcelo Santos Avatar answered Dec 09 '25 21:12

Marcelo Santos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!