Skip to content

Commit f315fe3

Browse files
committed
feat: support otp
1 parent f4a5bf6 commit f315fe3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/index.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@ const ReactInputVerificationCode = ({
135135
return;
136136
}
137137

138+
/**
139+
* otp code
140+
*/
141+
if (value.length > 1) {
142+
setValues(fillValues(eventValue));
143+
144+
const isCompleted = eventValue.length === length;
145+
146+
if (isCompleted) {
147+
onCompleted(eventValue);
148+
blurInput(index);
149+
return;
150+
}
151+
152+
return;
153+
}
154+
138155
setValue(value, index);
139156

140157
/**
@@ -216,6 +233,7 @@ const ReactInputVerificationCode = ({
216233
<div className='ReactInputVerificationCode-container'>
217234
{inputsRefs.map((ref, i) => (
218235
<input
236+
autoComplete='one-time-code'
219237
className='ReactInputVerificationCode-item'
220238
key={i}
221239
onChange={(event) => onInputChange(event, i)}

0 commit comments

Comments
 (0)