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

datepicker - Invalid date manually input is correctly detected in chrome but not in Firefox or IE. #3037

Closed
fortesl opened this issue Dec 1, 2014 · 5 comments

Comments

@fortesl
Copy link

fortesl commented Dec 1, 2014

for example entering date '50/12/2014' is detected as an invalid date in chrome as it should, but not in ie or firefox. Sample input tag shown below:

input type="text" class="form-control" datepicker-popup="MM/dd/yyyy" ng-model="ngModel" is-open="opened" close-text="Close" show-weeks="false" placeholder="" ng-required="true"

@jmayday
Copy link

jmayday commented Feb 10, 2015

Do you use the datepicker as a forms control? Did you check how the form field looks like by printing it as json?
<pre>My date object is: {{ myform.mydate | json }}</pre>
Please do so and observe the model value. Probably it was parsed as "Monday, February 12, 2018" (exactly like here http://angular-ui.github.io/bootstrap/#/datepicker).

I just commented on other issue (#3104) so just check it at the evening - I'll share my approach how to handle this problem.

@karianna
Copy link
Contributor

plunkr showing the problem please.

@jmayday
Copy link

jmayday commented Feb 11, 2015

@jmayday
Copy link

jmayday commented Feb 11, 2015

PR created: #3294
Please review. It came out that isNaN() method was returning different result under Firefox and Chrome allowing the latter to parse values not following pattern as dates. I removed new Date() call for these values as I found such behavior not desired.

@karianna karianna removed the PRs plz! label Feb 12, 2015
@rapmue
Copy link

rapmue commented May 8, 2015

I found also something interesting today. Maybe it's the same place to search the problem.

Using the newest version (0.13.0)

If you select a date format other than yyyy-mm-dd and your date input numbers aren't zero padded, the date is parsed wrong in Chrome. In InternetExplorer and Firefox it's not parsing at all, doesn't matter if with padding zeros or not.

Example: http://plnkr.co/edit/9TzjocE0P8F9gD7OwPoH?p=preview

Select date format dd.mm.yyyy and take as example today:

Chrome
input -> 8.5.2015
expected -> 2015-05-08
output -> 2015-08-05

input -> 08.05.2015
output -> 2015-05-08 as expected

Firefox
input -> 8.5.2015
error -> "Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date."

IE
input -> 8.5.2015
no output or error

Edit:
I think this bug is also discussed here: #3196

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

4 participants