// JavaScript Document
// This validation handles all fields and then issue an alert
function checkInput(form){
    var n, e, msg;
    n=document.forms[0].Name.value;
    msg='';
    if (n==''){
        msg="Name is mandatory\n";
    }
    e=document.forms[0].Email.value;
    if (e==''){
        msg=msg+"Email address is mandatory\n";
    } else {
        if (! isValidEmail(e)) {
            msg=msg+"Email address is invalid\n";
    	}
    }
	if ( msg == '' ) {
        return true;
    } else {
        alert(msg);
	    return false;
	}
}

// function to check valid email address
function isValidEmail(strEmail){
    validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
    // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) {
      return false;
    }
    return true;
}

