﻿var maxDigits = 11;
function nextDigit(txtDigit) {
    // Validate the entered value - single digits only
    var digit = Number(txtDigit.value);
    if (isNaN(digit)) {
        txtDigit.value = "";
        return false;
    }
    
    // Get the ID of the current digit
    var digitName = txtDigit.id;
    var digitID = Number(digitName.substr(digitName.lastIndexOf("Digit") + 5));
    if (digitID < maxDigits) {
        // If there are more boxes, move to the next one
        var baseName = digitName.substring(0, digitName.lastIndexOf("Digit") + 5);
        var nextDigitID = baseName + (digitID + 1);
        var nextDigit = document.getElementById(nextDigitID);
        nextDigit.focus();
    }
    return true;
}