// Returns whether the controlID passed is numeric and of the proper length
function NumericFormattedText(controlId, length) {
    var control = document.getElementById(controlId);   
    if (control != null && control.value != "") { // is there something similar to String.IsNullOrEmpty for here?
        var userValue = control.value;
        return (userValue.length == length && IsNumeric(userValue));
    }
    // value was null or empty
    return false;
    
}

function IsNullOrEmpty(controlId) {
    var control = document.getElementById(controlId);
    return (control != null) ? control.value == "" : true;
}

// Returns whether the text passed is numeric or contains some non-numeric character
function IsNumeric(text) {
    var s_len = text.length;
    var s_charcode = 0;
    for (var s_i=0;s_i<s_len;s_i++)
    {
        s_charcode = text.charCodeAt(s_i);
        if(!((s_charcode>=48 && s_charcode<=57)))
        {
            return false;
        }
    }
    return true;
}
