Created
January 29, 2014 07:09
-
-
Save awhitty/8683206 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<html> | |
<head> | |
<title>Email Form</title> | |
</head> | |
<body> | |
<form action=""> | |
<input type="text" placeholder="Email"> | |
<input type="submit"> | |
</form> | |
<!-- Firebase.js --> | |
<script type='text/javascript' src='https://cdn.firebase.com/js/client/1.0.2/firebase.js'></script> | |
<!-- jQuery --> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> | |
<script> | |
var fb = new Firebase(PUT_YOUR_FIREBASE_URL_HERE); | |
$('form').on('submit', function() { | |
var email_address = $('input').val() | |
if (validateEmail(email_address)) { | |
fb.child('emails').push(email_address) | |
}; | |
}) | |
function validateEmail(email) { | |
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
return re.test(email); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment