﻿function countChar(str, f) {
    document.getElementById(f).innerHTML = str.toString().length;
}

function formatPhone(f) {
    var txt = document.getElementById(f).value;
    txt = txt.replace(/[^0-9]/g, '');

    if (txt.length == 10) txt = '(' + txt.substr(0, 3) + ') ' + txt.substr(3, 3) + '-' + txt.substr(6, 4);

    document.getElementById(f).value = txt;
}

function formatURL(f) {
    var txt = document.getElementById(f).value;
    txt = txt.replace('http://', '');
    txt = txt.replace('https://', '');
    txt = txt.replace('ftp://', '');
    txt = txt.replace('ftps://', '');

    document.getElementById(f).value = txt;
}

function isAllUpper(fld, id) {
    var str = document.getElementById(id).value;
    

    if (isNaN(str) && str.toString().length > 10) {
        var up = (str == str.toUpperCase());

        if (up) {
            window.alert("We noticed you entered all capital letters in the '" + fld + "' field.  Sorry for the inconvenience, but we do not allow allow all capital letters in this field.  Please correct this error to continue!");
            document.getElementById(id).select();
        }
    }
}
