// prevent submit kapag no email address entry
//also password and confirm password sa line 35 ng contact.htm
// then line 27 of contact
//!= not equal
/*
password dapat
1. minimum of 8 character
2. at least one uppercase and one lower case
3. at least one number 
4. at least 1 special character
*/


/*below is version 1 one gawa ko gumagana naman but long version but easy to understand*/

/*
function preparePage(){
	document.getElementById("frmContact").onsubmit =function(){
		var password = document.getElementById("password").value;
		var cpassword = document.getElementById("cpassword").value;


		if(password.length < 8){
			document.getElementById("errorMessage").innerHTML ="Password must be at least 8 character.";
			return false;
		}


else if (password.search(/[a-z]/) < 0) {
  document.getElementById("errorMessage").innerHTML ="Password needs to have a lower case.";
  return false;
} 
else if(password.search(/[A-Z]/) < 0) {
  document.getElementById("errorMessage").innerHTML ="Password needs to have an upper case.";
  return false;
} 
else  if (password.search(/[0-9]/) < 0) {
  document.getElementById("errorMessage").innerHTML ="Password needs to have a number.";
  return false;
}
else  if (password.search(/[!@#$%^&*]/) < 0) {
  document.getElementById("errorMessage").innerHTML ="Password needs to have a special character.";
  return false;
}


		
		else if(password != cpassword){
			document.getElementById("errorMessage").innerHTML ="Password did not match.";
			return false;
		}

		else{
			document.getElementById("errorMessage").innerHTML ="";
			return true;
		}
	}
}
preparePage();
*/



/*below is version 2  gawa ni mam short but
harder to understand */

function preparePage(){
	document.getElementById("frmContact").onsubmit =function(){
		var password = document.getElementById("password").value;
		var cpassword = document.getElementById("cpassword").value;

if (!password.match("(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@#$%^&*-])(.{8,})")){
	document.getElementById("errorMessage").innerHTML ="Password must be 8 characters, must have 1 number, 1 special character and at least 1 uppercase.";
		return false;
}

else if(password != cpassword){
			document.getElementById("errorMessage").innerHTML ="Password did not match.";
			return false;
		}

		else{
			document.getElementById("errorMessage").innerHTML ="";
			return true;
		}
	}
}
preparePage();