LocoThatCould,
<form id="fr">
<input type="text" id="username" />
<input type="password" id="pass" />
<input type="submit" />
</form>
<script>
document.querySelector('#fr').addEventListener('submit', function(e) {
if (!validate())
e.preventDefault();
});
var userEmail = document.getElementById("username"),
userPass = document.getElementById("pass"),
regexp = new RegExp("^([a-z0-9_-]+\.)*[a-z0-9_-]+@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[a-z]{2,6}$"),
regexpP = new RegExp("^[a-zA-Z0-9!@#$%^&*]{6,16}$");
function validate() {
var result = regexp.test(userEmail.value);
if (!result) {
userEmail.style.border = "2px solid red";
alert('Некорректно введен Email!');
} else
userEmail.style.border = "2px solid green";
if (!regexpP.test(userPass.value)) {
result = false;
userPass.style.border = "2px solid red";
alert('Некорректно введен Пароль!')
} else
userPass.style.border = "2px solid green";
return result;
}
</script>