心平凡,自不凡
我时常想象自己沿着视野里的湖边一遍一遍的走着,看着春天的枝叶发出新芽,夏天里漫天飞舞的柳絮,秋日里被寒霜染红的落叶,冬日里最最欣喜的漫山遍野的雪景,料想这原本就是自己的一生,但自从遇见了不安,便让自己脱离里梦境,游走在时间与欲望的边缘,时而快乐着时而忧伤着的挥霍自己的青春。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#verificationCode input {
width: 40px;
height: 40px;
font-size: 24px;
text-align: center;
}
</style>
</head>
<body>
<div id="verificationCode">
<input type="text" maxlength="1" />
<input type="text" maxlength="1" />
<input type="text" maxlength="1" />
<input type="text" maxlength="1" />
<input type="text" maxlength="1" />
<input type="text" maxlength="1" />
</div>
<script>
const verificationCodeInputs = document.querySelectorAll('#verificationCode input');
verificationCodeInputs.forEach((input, index) => {
input.addEventListener('input', (e) => {
const currentInput = e.target;
const nextInput = verificationCodeInputs[index + 1];
const previousInput = verificationCodeInputs[index - 1];
if (currentInput.value !== '') {
currentInput.value = currentInput.value[0]; // Only allow single character input
if (nextInput && currentInput.value !== '') {
nextInput.focus(); // Move focus to the next input box
}
} else if (previousInput) {
previousInput.focus(); // Move focus to the previous input box
}
});
});
</script>
</body>
</html>