Date Picker and Input Field Validation Discrepancy


Topic: Date Picker and Input Field Validation Discrepancy

jcarvalho pro premium priority asked 4 days ago

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?


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


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • 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