function autoTab(e, element, nextElement) 
{
    var key = (!e) ? window.event : e.which;
    
    if( key != 9 && key != 16 )
    {
        if (element.value && element.value.length == element.maxLength && nextElement != null) {
            element.form.elements[nextElement].focus();
            element.form.elements[nextElement].select();
        }
    }
}

function regexCheck(str, regexPattern)
{
    return regexPattern.test(str);
}

function emailCheck(field, message)
{
    if( field.val() == "" || !regexCheck(field.val(), /([\w-\.]+)@((?:[\w]+\.)+)([a-zA-Z]{2,4})/) )
        return false;

    return true;
}

function numericCheck(field, message)
{
    //allows numeric characters only
    if( field.val() == "" || regexCheck(field.val(), /[^0-9]/) )
        return false;

    return true;
}

function alphaNumericPlusCheck(field, message)
{
    //allows alpha-numeric characters plus . - _ , and spaces.
    if( field.val() == "" || regexCheck(field.val(), /[^a-zA-Z0-9\.\-\_\s\,]/) )
        return false;

    return true;
}
