Skip to content
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

Date Picker improvement #265

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,25 @@ <h1><br>Want to <span>Share</span> or <span>Rent</span> <br>a cab.</h1>
<label for="pickupDate">Pickup Date</label>
<input type="date" id="pickupDate">
</div>
<script>
const today = new Date();
const yesterday = new Date(today.setDate(today.getDate())).toISOString().split('T')[0];
document.getElementById('pickupDate').setAttribute('min', yesterday);
</script>
<div class="form-group">
<label for="dropoffDate">Drop-off Date</label>
<input type="date" id="dropoffDate">
</div>
<script>
const minDateInput = document.getElementById('pickupDate');
const maxDateInput = document.getElementById('dropoffDate');
minDateInput.addEventListener('change', function() {
const selectedMinDate = new Date(minDateInput.value);
// Set max date as selected min date
const maxDate = new Date(selectedMinDate.setDate(selectedMinDate.getDate())).toISOString().split('T')[0];
maxDateInput.setAttribute('min', maxDate);
});
</script>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not add new script tags, add this script in the tag at the at line 612.

Also, look at why the css is showing that there are error even after the first load:

Current Version:
Screenshot 2024-10-12 at 12 43 21 AM

Changes in this PR:
Screenshot 2024-10-12 at 12 43 26 AM

<div class="form-group">
<button id="bookNow">Book Now</button>
Expand Down
Loading