// JavaScript Document

function checkEmail(myEmail) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myEmail)){
		return '';
	}

	return 'Invalid Email address! Please re-enter.';
	
}

function checkPassword( pw1, pw2 ) {
	var invalid = " "; // Invalid character is a space
	var minLength = 6; // Minimum length
	
	// check for a value in both fields.
	if (pw1 == '' || pw2 == '') {
		
		return 'Please enter your password twice.';		
	}
	
	// check for minimum length
	if (pw1.length < minLength) {
		
		return 'Your password must be at least ' + minLength + ' characters long. Try again.';
	}
	// check for spaces
	if (pw1.indexOf(invalid) > -1) {

		return "Sorry, spaces are not allowed.";
	} else {
		
		if (pw1 != pw2) {

			return "You did not enter the same new password twice. Please re-enter your password.";
		} else {
		
			return '';
      }
   }
}
