Course lesson
Implement Conditional Logic in a Zag.js Action to Enforce a Single Character Per Input
We have a bug in our pin input. Only 1 value should be allowed per input but if we focus an input that already has a value we can still input another value.
- Duration
- 6 min
- Access
- Free
- Transcript
- Retained from source evidence
We have a bug in our pin input. Only 1 value should be allowed per input but if we focus an input that already has a value we can still input another value.
Let's fix that.
We'll need to implement a function getNextValue that will take in the focused value of the current input and the event input that is coming in. After a set of conditionals we will select the value that wasn't the current focused value to update the field.