Last active
May 18, 2016 02:54
-
-
Save CodeMonkeyG/631fa29b12dea5043c9fe5065a14fcca to your computer and use it in GitHub Desktop.
Gigya Global Config for BeachBody
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
// Global Gigya Configutatio object | |
window.__gigyaConf = { | |
customLang: { | |
invalid_login_or_password : 'The Current Password you entered is incorrect. Try again or <a href="http://beachbodyglobal.com/forgot-password/">click here to reset your password</a>.' | |
}, | |
validation: { | |
// formData contains all information user has entered | |
// eventType is either "change" or "keypress" | |
// callback is optional, you can use it for asynchronous validation or just use return | |
'gigya-login-screen': function(formData, eventType, callback){ | |
var errors = {}; | |
var emailRegEx = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; | |
if(!emailRegEx.test(formData['loginID'])){ | |
// You can return errors OR use callback for validation via AJAX. | |
errors['username'] = 'Please enter a valid email address'; | |
errors['loginID'] = 'Please enter a valid email address'; | |
} | |
return errors; | |
}, | |
'gigya-forgot-password-screen': function(formData, eventType, callback){ | |
var errors = {}; | |
var emailRegEx = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; | |
if(!emailRegEx.test(formData['loginID'])){ | |
// You can return errors OR use callback for validation via AJAX. | |
errors['username'] = 'Please enter a valid email address'; | |
errors['loginID'] = 'Please enter a valid email address'; | |
} | |
return errors; | |
}, | |
'gigya-complete-registration-screen': function(formData, eventType, callback) { | |
var errors = {}; | |
var year = parseInt(formData['profile.birthYear'], 10); | |
var month = parseInt(formData['profile.birthMonth'], 10); | |
var day = parseInt(formData['profile.birthDay'], 10); | |
var today = Date.now(); | |
var date; | |
var thirteenYears = 31556952000 * 13; //Includes leap year | |
// Confirm user is 13 years of age | |
date = new Date(year, month - 1, day); | |
if((today - date.getTime()) < thirteenYears ){ | |
errors['compositeBirthdate'] = 'You must be 13 years or older to register'; | |
} | |
// Override default error message for required fields. | |
if(!day | |
|| !month | |
|| !year | |
|| day > 31 | |
|| month > 12 | |
|| year > today.getFullYear() | |
|| (formData['profile.birthDay'] + '').length != 2 | |
|| (formData['profile.birthMonth'] + '').length != 2 | |
|| (formData['profile.birthYear'] + '').length != 4){ | |
errors['compositeBirthdate'] = 'Please enter a valid date'; | |
} | |
if(!errors['compositeBirthdate']){ | |
$('.gigya-full-birthDate-composite-control input').removeClass('gigya-error').addClass('gigya-valid'); | |
$('.gigya-error-msg[data-bound-to="compositeBirthdate"]').removeClass('gigya-error-msg-active'); | |
} else { | |
$('.gigya-full-birthDate-composite-control input').removeClass('gigya-valid').addClass('gigya-error'); | |
} | |
return errors; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment