Skip to content
Discussion options

You must be logged in to vote

You're using the wrong validation attributes. maxLength and minLength are the type="text" input attributes. HTML5 forms API doesn't have any type="date" validation API.

What you can do is to utilize the RHF validate callback and provide multiple validation functions in a form of object for ease of use. Something like this:

rules={{
  validate: {
    minDate: (date) =>
      isAfter(new Date(date), new Date("1993/11/11")) ||
      "Please, enter a date after 1993/11/11",
    maxDate: (date) =>
      isBefore(new Date(date), new Date("2022/25/07")) ||
      "Please, enter a date before 2022/25/07"
  }
}}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@julio3266
Comment options

@Moshyfawn
Comment options

Answer selected by julio3266
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants