react-hook-form / documentation

📋 Official documentation
http://react-hook-form.com
MIT License
726 stars 1.04k forks source link

issue: maxLength does not limit input field to length #1043

Open MylesWardell opened 10 months ago

MylesWardell commented 10 months ago

Version Number

7.49.3

Codesandbox/Expo snack

https://codesandbox.io/s/intelligent-poincare-f57gmx

Steps to reproduce

  1. Go to input
  2. See that maxLength is 3
  3. type and see that its allows more than 3

Expected behaviour

image Text says max Length accepted by this input so I would assume its a passthrough to maxLength on the react input. If it was just validation it should say maxLength the input is validated or something like that.

What browsers are you seeing the problem on?

Chrome

Relevant log output

No response

Code of Conduct

Moshyfawn commented 10 months ago

The prop does not appear to be documented, but you can enable the passing of native validation props to input elements by using the progressive: true flag on useForm.

If it was just validation it should say maxLength the input is validated or something like that.

Validation is only performed based on the mode prop, which defaults to onSubmit. This means that your expected validation error would occur on form submission. If you require validation to occur onChange, consider using mode: "onChange".