fix(verify-account-ui): Cannot read property 'focus' of undefined

pull/43/head
yolo 5 years ago
parent d24b8bd9cf
commit 47c916c27b

@ -1,4 +1,5 @@
const codes = document.querySelectorAll('.code')
const length = codes.length
codes[0].focus()
@ -6,8 +7,14 @@ codes.forEach((code, idx) => {
code.addEventListener('keydown', (e) => {
if(e.key >= 0 && e.key <=9) {
codes[idx].value = ''
if(length - 1 == idx) {
return
}
setTimeout(() => codes[idx + 1].focus(), 10)
} else if(e.key === 'Backspace') {
if(idx == 0) {
return
}
setTimeout(() => codes[idx - 1].focus(), 10)
}
})

Loading…
Cancel
Save