New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dateinput] Bug :: Invalid year selector when setting 2nd calendar min to value of 1st calendar #156

Closed
rumyagent opened this Issue Sep 1, 2010 · 3 comments

Comments

Projects
None yet
3 participants
@rumyagent

Using the below code to initialize 2 date inputs. Showing month/year selectors. Second date input cannot have a date before the first input.

If a user selects Dec of whatever year (Dec 1, 2010 for example), the 2nd calendar YEAR dropdown changes to the next year (2011 in our example). When a user clicks a day on that calendar, it populates with input with the right date (2010) however it is confusing to the user as they would think they're choosing 2011 (and that there is NO way they can choose Dec 2010 for the 2nd date)

Try it out here

<input type="date" name="bill[start]" value="mm/dd/yyyy" /> 
<input type="date" name="bill[end]" value="mm/dd/yyyy" /> 

$(":date").dateinput({
    selectors: true,
    trigger:true
});

$(":date:first").data("dateinput").change(function() {
    $(":date:last").data("dateinput").setMin(this.getValue(), true);
});
@bradrobertson

This comment has been minimized.

Show comment
Hide comment
@bradrobertson

bradrobertson Sep 7, 2010

Contributor

Not sure why, but line 506 (v1.2.3) for choosing what valid year select options compares min value with, new Date(i+1,-1,0). This makes a Date that is always Nov 30th of whatever year. Can someone enlighten me as to why -1 was chosen for the month here? Obviously any min value in Dec won't match the current year for the year selectors which I believe is wrong. I've pasted a patch below

Contributor

bradrobertson commented Sep 7, 2010

Not sure why, but line 506 (v1.2.3) for choosing what valid year select options compares min value with, new Date(i+1,-1,0). This makes a Date that is always Nov 30th of whatever year. Can someone enlighten me as to why -1 was chosen for the month here? Obviously any min value in Dec won't match the current year for the year selectors which I believe is wrong. I've pasted a patch below

@bradrobertson

This comment has been minimized.

Show comment
Hide comment
@bradrobertson

bradrobertson Sep 7, 2010

Contributor
506c506
<   if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) {
---
>   if (min < new Date(i + 1, 0, 0) && max > new Date(i, 0, 0)) {
Contributor

bradrobertson commented Sep 7, 2010

506c506
<   if (min < new Date(i + 1, -1, 0) && max > new Date(i, 0, 0)) {
---
>   if (min < new Date(i + 1, 0, 0) && max > new Date(i, 0, 0)) {

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment