Skip to content

Instantly share code, notes, and snippets.

@jaxbot
Created September 10, 2015 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaxbot/95c7720cbea4c91cb04b to your computer and use it in GitHub Desktop.
Save jaxbot/95c7720cbea4c91cb04b to your computer and use it in GitHub Desktop.
if (!window.Bastide) window.Bastide = {};
window.Bastide.Registration = {
signup: function() {
var nameInput = document.querySelector('#signUpModal .name'),
emailInput = document.querySelector('#signUpModal .email'),
schoolInput = document.querySelector('#signUpModal .school');
var params = {
name: nameInput.value,
email: emailInput.value,
school: schoolInput.value,
};
var error = false;
if (!params.name) {
error = true;
nameInput.className += " invalid";
}
if (!params.email || !Bastide.Helpers.validateEmail(params.email)) {
error = true;
emailInput.className += " invalid";
}
if (!params.school) {
error = true;
schoolInput.className += " invalid";
}
var errorMessage = document.querySelector('#signUpModal .errors');
if (error) {
errorMessage.className += ' visible';
return false;
} else {
errorMessage.className = errorMessage.className.replace(/ visible/g, '');
}
if (window.DEV)
_handleSignupCompleted();
else
Bastide.ajax("/api/registration/signup", params, _handleSignupCompleted);
}
};
function _handleSignupCompleted(data) {
$('#signUpModal').foundation('reveal', 'close');
$('#signUpCompletedModal').foundation('reveal', 'open');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment