Без стрелочек и пр.
Email<input type='text' id = 'username'>
Password<input type='text' id = 'pass'>
<button>Тест</button>
<div id='result'></div>
<script>
var userEmail = document.getElementById("username"),
userPass = document.getElementById("pass");
var regexp = new RegExp("^([a-z0-9_-]+\.)*[a-z0-9_-]+@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[a-z]{2,6}$");
var regexpP = new RegExp("^[a-zA-Z0-9!@#$%^&*]{6,16}$");
document.querySelector('button').onclick = function() {
result.textContent = validate();
}
function validate() {
var resultE = false, resultP = false;
if(!regexp.test(userEmail.value)) {
userEmail.style.border = "2px solid red";
} else {
userEmail.style.border = "2px solid green";
resultE = true;
}
if(!regexpP.test(userPass.value)) {
userPass.style.border = "2px solid red";
} else {
userPass.style.border = "2px solid green";
resultP = true;
}
return resultP && resultE;
}
</script>