Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Datepicker return invalid date if I enter the date by keyboard - firefox 39 #4040

Closed
rrawrriw opened this issue Jul 29, 2015 · 1 comment
Closed

Comments

@rrawrriw
Copy link

Hello,

first, thanks for your effort to build this lovely helper library.

I attempt to build a search form where you can search documents by date. So I used the datepicker directive. You can choose the date with the popup or enter it with the keyboard in a input field. When I use the popup it works fine. However if I enter the date with the keyboard it dosen't work. I made a small Plunker example http://plnkr.co/Nc58sJjWE9cmItRmkSwg. What I sad is just right for the firefox 39 when I use chrome 43 it works fine.

When you open the plunker example and put in a date in format dd.MM.yyyy an hit the GO! button you shouldn't get a valid date printed out in the debug-console.

I checked out the code and find out that following event listener dosen't work always in firefox 39. Also the Date function in firefox can not handle a string in the given format. So we don't have a right baseDate in the parser function.

      ngModel.$viewChangeListeners.push(function () {
        if (dateParser.parse(ngModel.$viewValue, dateFormat, scope.date)) {
          scope.date = dateParser.parse(ngModel.$viewValue, dateFormat, scope.date);
        } else {
          scope.date = new Date(ngModel.$viewValue);
        }
      });

If I make a simple example without ui-bootstrap. Just a handmade directive where I registred a function at the change listener it works fine in firefox an chrome.

Hopefully you can understand my english. And hopefully I didn't missed something elementary and have been wasting your time?

Best regards, Tim.

@wesleycho
Copy link
Contributor

This is a duplicate of #3713

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants