//=================================================
// name: frmCheck.js
// author: Uriah Liggett
// date: 06/23/04
//=================================================

function checkMinMaxLength(text, min, max, name)
{    
    return checkMinLength(text, min, name) && checkMaxLength(text, max, name);
}

function checkMinLength(text, length, name)
{
    if(text.length < length)
    {
        alert(name + " must be at least " + length + " characters");
        return false;
    }
    
    return true;    
}

function checkMaxLength(text, length, name)
{
    if(text.length > length)
    {
        alert(name + " can be no more than " + length + " characters");
        return false;
    }
    
    return true;    
}

function checkText(text)
{    
    
    var validChars = new Array( "a", "b", "c", "d", "e", "f", "g", "h", "i"
            , "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v"
            , "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6","7","8"
            , "9", "!", "#", ".", "@", "^", "_", "-", " ","/",":",",","?","+","$","%","&","(",")","!","/",":","-","'","!","\"",";","\n","\r","®","©");
            
    var isValid;    
    
    for(var i=0; i < text.length; i++)
    {
        isValid = false;
        for(var j=0; j < validChars.length; j++)
        {
            if(text.toLowerCase().charAt(i) == validChars[j])
            {
                isValid = true;
                break;
            }
        }
        
        if(!isValid)
        {
            alert("The string " + text + " contains invalid characters.");            
            return false;
        }        
    }
    
    return true;
}
