// form.js

// validates that the field value string has one or more characters in it
function isNotEmpty(elem) {

	var str = elem.value;
    var field = elem.name;
    
	if (((elem.type=="text"||elem.type=="textarea")&& elem.value=='')) {
		alert('You must fill in the ' + field + ' field.');
        return false;
    } else {
        return true;
    }
}

function validate(form) {
	if (isNotEmpty(form.email)) {
		return true;
	}
    return false;
}

// validates that the entry is formatted as an email address
function isEmailAddr(elem) {
    var str = elem.value;
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        alert("The e-mail address you have entered appears to be invalid - please check and try again.");
        return false;
    } else {
        return true;
    }
}
