Skip to content

Commit

Permalink
date validated
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhipai78 committed Jun 1, 2024
1 parent 97bc63f commit 7b0a13a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plantrip.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,20 @@
outline: none;
}
</style>
<script>
<script>
function handleSubmit(event) {
event.preventDefault();
const today = new Date();
const startDate = new Date(document.getElementById('startDate').value);
const endDate = new Date(document.getElementById('endDate').value);

if (endDate < startDate) {
alert('End date cannot be earlier than start date.');
} else if (startDate < today || endDate < today) {
alert('Start and end dates cannot be earlier than today.');
} else {
alert('Trip planned successfully!');
// You can proceed to submit the form or perform other actions here
// For demonstration, form submission is prevented.

}
}

Expand Down

0 comments on commit 7b0a13a

Please sign in to comment.