﻿function validateEmpty(fld, error) {

    if (fld.value.length == 0) {
        fld.focus();
        return error;
    }

    return "";
}

function trim(s) {
    return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld,error) {    
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/;

    if (!emailFilter.test(tfld)) {
        fld.focus();
        return error;
    }
       
    return "";
}
