
function validatePassword (strng) {
 	var error = "";
 	
	var strng = strng.replace(/[" "]/g, '');
	if (strng == "") {
    	error = "You didn't enter a valid password.\n";
 	}
	return error;

}


/*
    When it comes to passwords, we want to be strict with our users. 
  	It's for their own good; we don't want them choosing a password that's
  	easy for intruders to guess, like a dictionary word or their kid's birthday.
  	So we want to insist that every password contain a mix of uppercase and 
  	lowercase letters and at least one numeral. 
  	We specify that with three regular expressions, a-z, A-Z, and 0-9, 
  	each followed by the + quantifier, which means "one or more," 
  	and we use the search() method to make sure they're all there:
*/


function validatePasswordFormat(strng) {
 	
	var error = "";
 	var illegalChars = /[\W_]/; // allow only letters and numbers
    
	var PasswordReg = /^\w*(?=\w*\d)(?=\w*[a-zA-Z])\w*$/
	
	var strng = strng.replace(/[" "]/g, '');
	
	if (strng == "") {
    	error = "You didn't enter a valid password.\n";
 	
	} else if (strng.length < 8 || strng.length > 15) {
       	error = "Please enter a password between 8 and 14 characters long.\n"
    
	} else if (!PasswordReg.test(strng)){ 
		error = "Password must contain at least one alphabet and at least one number.\n"
    }
	
	return error;
}




/*
    When it comes to passwords, we want to be strict with our users. 
  	It's for their own good; we don't want them choosing a password that's
  	easy for intruders to guess, like a dictionary word or their kid's birthday.
  	So we want to insist that every password contain a mix of uppercase and 
  	lowercase letters and at least one numeral. 
  	We specify that with three regular expressions, a-z, A-Z, and 0-9, 
  	each followed by the + quantifier, which means "one or more," 
  	and we use the search() method to make sure they're all there:
  
	var illegalChars = /[\W_]/; // allow only letters and numbers
    if ((strng.length < 6) || (strng.length > 8)) {
       error = "The password is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The password contains illegal characters.\n";
    }
	else if (!((strng.search(/(a-z)+/))&& (strng.search(/(A-Z)+/))&& (strng.search(/(0-9)+/)))) {
  		error = "The password must contain at least one 
    	uppercase letter, one lowercase letter,
    	and one numeral.\n";
  	}
*/
