Skip to content

Instantly share code, notes, and snippets.

@edprince
Created May 7, 2015 20:15
Show Gist options
  • Save edprince/d64e0c70c807eed079dd to your computer and use it in GitHub Desktop.
Save edprince/d64e0c70c807eed079dd to your computer and use it in GitHub Desktop.
var form = document.getElementById('registration');
form.addEventlistener('submit', function() {
if (check()) {
return true;
} else {
return false;
}
});
function check(){
var pass1 = document.getElementById('password').value;
var pass2 = document.getElementById('re-password').value;
var email = document.getElementById('email').value;
if (!checkPasswordsMatch(pass1, pass2)) && (!checkEmailFormat(email)) {
return false;
}
}
function checkPasswordsMatch (pass1, pass2) {
//returns boolean
return (pass1 === pass2);
}
function checkEmailFormat(email) {
var regex = /.*@.*\..*/;
//returns boolean
return (regex.test(email));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment