⚠️ This lesson is retired and might contain outdated information.

Limit or Control What gets Input into a redux-form Field using normalizing

Rory Smith
InstructorRory Smith
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 2 years ago

Sometimes we need to add a limitation to what the user is inputting into a redux-form Field. For example, in a license plate lookup, we want all the letters to be uppercase regardless of whether the user types them in caps, or when taking a user’s name, we may want the format to be capitalized.

Instructor: [00:00] Using Redux Form, we can use normalization to format the user's input. For example, we could ensure that the user's first name and surname are capitalized, regardless of how they type the values into the fields.

[00:15] The demonstrate this, let's go ahead and add capitalize as a dependency. We can import that in our register form. Now, we can use the normalize prop, and pass in the capitalize function. Let's apply this to the first name and the surname. Of course, you could pass whichever function you wanted in here.

[00:45] Let's save and refresh now. Now, even if I type everything lowercase, the values are capitalized.

azimjon
azimjon
~ 6 years ago

How to dynamically pass options to customSelect from register form Field?

Gareth
Gareth
~ 6 years ago

The values aren't capitalized in the UI result. Also why not just use String.toUpperCase() versus installing another npm package.

Gareth
Gareth
~ 6 years ago

My bad. It capitalizes the first letter. Missed that.

Markdown supported.
Become a member to join the discussionEnroll Today