Reputation: 117
I'm using Mui datepicker, with the format yyyy-MM-dd. If the user writes the a value with only one day (yyyy-MM-d), like 2020-12-1, this get converted to 2020-12-01.
Is there a way to assert that the user has to write two digits?
Here is a link to the datepicker demo where you can see how it works.
Upvotes: 0
Views: 880
Reputation: 643
You can use third party library to help with form validation. For example, React hook form. DatePicker
API exposes inputRef
so this is possible.
Upvotes: 0