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

Fixes #579: Resolved entering date issue #608

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

byteom
Copy link
Contributor

@byteom byteom commented Oct 24, 2024

Fixes #579

Summary of Changes:

  • Issue: Users were able to enter more than four digits for the year in the "Date of Journey" field, resulting in an invalid date format On this page - https://ticket-booking-blue.vercel.app/buy.html.

  • Fix: Implemented restrictions to ensure the year part of the date input does not exceed four digits.

Changes Made:

  1. JavaScript Validation:

    • Added a validation script to enforce strict date input. The script checks that the date entered follows the YYYY-MM-DD format and restricts any input beyond 10 characters, preventing users from entering more than four digits for the year.
    document.getElementById('journeyDate').addEventListener('input', function() {
        const datePattern = /^\d{4}-\d{2}-\d{2}$/;
        if (!datePattern.test(this.value)) {
            this.value = this.value.slice(0, 10); // Restrict to the YYYY-MM-DD format
        }
    });
  2. Html code Updation:

  • specify a max attribute in the input[type="date"] field to limit the possible year range
     <div class="form-group">
  <label for="journeyDate">Date of Journey</label>
  <input type="date" id="journeyDate" name="journeyDate" required max="9999-12-31">
</div>


Fixes #579 

Here is the ScreenShot not taking 6 digit 

![image](https://github.com/user-attachments/assets/e504e116-659a-4412-9666-b4eb48cf6b03)


## Type of change

## Type of change

<!-- Please delete bullets that are not relevant. -->

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] Chore (refactoring code, technical debt, workflow improvements)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update


## Screenshots 
![image](https://github.com/user-attachments/assets/e504e116-659a-4412-9666-b4eb48cf6b03)
## Mandatory Tasks

- [x] Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Copy link

vercel bot commented Oct 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ticket-booking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 24, 2024 8:03pm

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🎉 Thank you @byteom for your contribution! Your pull request has been submitted successfully. A maintainer will review it as soon as possible. We appreciate your support in making this project better

@ankit071105 ankit071105 merged commit c26de25 into ankit071105:main Oct 25, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] In enetring date section
2 participants