Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features
Autoplay

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

    Rory SmithRory Smith
    reactReact
    ^16.0.0
    reduxRedux
    ^3.0.0

    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.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    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.

    Discuss

    Discuss