Topic: Date Picker and Input Field Validation Discrepancy
Hello, I'm using the mdb date picker component and have set a min date of 05/01/2020. However, I noticed that if I manually enter a date like 01/01/0001 (which is an invalid date in this case) into the input field, it's still treated as a valid date.
Shouldn't the input field and the date picker be tied together in terms of validation, such that the entered date is also checked against the min (and max) constraints? It seems like the manual input is bypassing the date range validation.
Could you clarify if this is expected behavior, or if there's an additional step needed to enforce consistent validation?
Arkadiusz Idzikowski
staff answered a day ago
For inputs we just use basic built-in Angular validators so in this case it is probably expected behavior, because those validators will recognize only simple values like strings or numbers.
Sadly, we don't have a custom validator for the datepicker component, but you could try to build a new one and adjust it to your needs: https://angular.dev/guide/forms/form-validation#defining-custom-validators
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Pro
- Premium support: Yes
- Technology: MDB Angular
- MDB Version: MDB5 8.0.0
- Device: Laptop
- Browser: Chrome
- OS: Mac - IOS
- Provided sample code: No
- Provided link: No