jquense / react-formal

Sophisticated HTML form management for React
http://jquense.github.io/react-formal
MIT License
526 stars 52 forks source link

Using maxlength on input with react formal #95

Closed mjrussell closed 8 years ago

mjrussell commented 8 years ago

I have an input field which is only allowed to take a maximum of 6 characters. I know I can use react formal with yup to create a schema that enforces it on validation. However, I'd like the input element to not accept more than 6 characters (like you can do with HTML5's maxlength). Using an alternative form element (setting component to div) doesn't seem to do this either despite there no longer being a novalidate on the parent.

Do you have any suggestions on how to do this? I was wondering if there might also be a onChange or transform approach to prevent the value from changing above 6 characters even after the user types in the field

jquense commented 8 years ago

I think that setting maxLength on the input should work, no?

mjrussell commented 8 years ago

Wow...Im embarrassed. Yeah If you camel case maxLength like you are supposed to in React it works just fine. 😞

jquense commented 8 years ago

haha Np, glad it worked