if (e.key >= 0 && e.key <= 9) {
// If the input field is not empty, it will move to the next input field
codes[idx].value = '';
//
if(idx+1<codes.length)//
{
setTimeout(() => codes[idx + 1].focus(), 10);
}
}
// Checking if the key pressed is backspace
else if (e.key.toLowerCase() === 'backspace') {
// If the input field is empty, it will move to the previous input field
if(idx-1>=0)//
{
setTimeout(() => codes[idx - 1].focus(), 10);
}
}
if (e.key >= 0 && e.key <= 9) {
// If the input field is not empty, it will move to the next input field
codes[idx].value = '';
//
if(idx+1<codes.length)//
{
setTimeout(() => codes[idx + 1].focus(), 10);
}
}