Created
May 7, 2015 20:15
-
-
Save edprince/d64e0c70c807eed079dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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