Registered in-store?
Activate your online account by entering your login details and membership number. Then enter a password of your choosing.
Please select your membership type below:
$(this).closest('#fr-registerWithScsOfflineMemberFormConfigWrapper').find('.js-fr-registerWithScsOfflineMemberFormConfig')
.formValidation(
{
autoFocus: false,
framework: 'bootstrap',
icon: {
valid: null,
invalid: null,
validating: null
},
fields: {
'values[registerWithScsOfflineMemberFormDefinition_membershipNumber]': {
trigger: 'blur',
validators: {
callback: {
callback: function(value, validator, $field) {
var messages = [];
var messagesEN = [];
var errorOccured = false;
if ($field.attr('regexCheckDisabled') === 'true') {
return true;
}
if (!value.trim().match(new RegExp('^(\\d{3}(-*)\\d+)?$', ''))) {
messages.push('Please enter a valid membership number in format 123-45455');
messagesEN.push('Please enter a valid membership number in format 123-45455');
errorOccured |= true;
}
if (errorOccured) {
return {
valid: false,
message: messages.join('<br/>'),
message_en: messagesEN
}
} else {
return true;
}
}
},
notEmpty: {
message: 'Membership number field cannot be empty',
message_en: 'Membership number field cannot be empty'
},
stringLength: {
message: 'The number of characters for this field must be between 0 and 11',
message_en: 'The number of characters for this field must be between 0 and 11',
min: 0
,
max: 11
},
}
},
'values[registerWithScsOfflineMemberFormDefinition_email]': {
trigger: 'blur',
validators: {
regexp: {
regexp: new RegExp('^(?=.{0,255}$)(?=.{0,64}@)(?:(?!^\\.)(?!.*\\.@)(?!.*\\.\\.)[a-zA-Z0-9!#.$%&\'*+\/=?^_‘{|}~-]+|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f]){1,62}\")@(?!-)(?!.*\\.-)(?!.*-\\.)(?:[a-zA-Z0-9-]{1,61}\\.){1,126}(?=[a-zA-Z0-9-]*[a-zA-Z][a-zA-Z0-9-]*$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$', ''),
message: 'Please enter your email address.',
message_en: 'Please enter your email address.'
},
notEmpty: {
message: 'Please enter your email address.',
message_en: 'Please enter your email address.'
},
stringLength: {
message: 'The number of characters for this field must be between 1 and 70',
message_en: 'The number of characters for this field must be between 1 and 70',
min: 1
,
max: 70
},
}
},
'values[registerWithScsOfflineMemberFormDefinition_password]': {
trigger: 'blur',
validators: {
callback: {
callback: function(value, validator, $field) {
var messages = [];
var messagesEN = [];
var errorOccured = false;
if ($field.attr('regexCheckDisabled') === 'true') {
return true;
}
if (!value.match(new RegExp('(^$|^(?=.*[0-9])(?=.*[A-Z]).{7,}$)', ''))) {
messages.push('The password must be at least 7 characters long and contain a number and a capital letter.');
messagesEN.push('The password must be at least 7 characters long and contain a number and a capital letter.');
errorOccured |= true;
}
if (errorOccured) {
return {
valid: false,
message: messages.join('<br/>'),
message_en: messagesEN
}
} else {
return true;
}
}
},
notEmpty: {
message: 'Please set a password.',
message_en: 'Please set a password.'
},
stringLength: {
message: 'You have exceeded the maximum length of 64 characters for this field',
message_en: 'You have exceeded the maximum length of 64 characters for this field',
max: 64
},
}
},
'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]': {
err: "#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince-date-error-messages",
excluded: false,
trigger: 'blur',
validators: {
callback: {
message: '\u003Cspan style=\'color:#ff0000;\'\u003Eerror.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidDay, error.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidDay\u003C\/span\u003E',
message_en: '\u003Cspan style=\'color:#ff0000;\'\u003Eerror.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidDay, error.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidDay\u003C\/span\u003E',
callback: function(value, validator, $field) {
var input = $('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day');
if($('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month').val() && value && $('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year').val()){
var currentDate = new Date().getTime();
var fieldsDDMMYYYY = value ? new Date($('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month').val() + "." + value + "." + $('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year').val()).getTime() : new Date().getTime() + 1;
if(typeof fieldsDDMMYYYY == "number" && ((fieldsDDMMYYYY > currentDate)||(fieldsDDMMYYYY < currentDate))) {
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year]');
}
}
if (ACC.global.isDateFieldEmpty("registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince")) {
if ($("small[data-fv-for='" + 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month]' +"']").attr('data-fv-result') == "INVALID") {
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month');
}
if ($("small[data-fv-for='" + 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year]' +"']").attr('data-fv-result') == "INVALID") {
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year]');
}
input.addClass('date-input-no-confirmation');
return true;
} else {
input.removeClass('date-input-no-confirmation');
}
if ($field.val().match("^\\d+$") == null) {
return false;
}
var value = parseInt($field.val());
var monthValue = $('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month').val();
var yearValue = $('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year').val();
if (monthValue == "" && yearValue == "") {
return value >= 1 && value <= 31;
}
if (monthValue == "2" && yearValue == "") {
return value >= 1 && value <= 29;
}
var month = parseInt(monthValue);
var year = parseInt(yearValue);
return value >= 1 && value <= ACC.global.numberOfDaysInMonth(month, year);
}
}
}
},
'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month]': {
err: "#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince-date-error-messages",
excluded: false,
trigger: 'blur',
validators: {
callback: {
message: '\u003Cspan style=\'color:#ff0000;\'\u003Eerror.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidMonth, error.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidMonth\u003C\/span\u003E',
message_en: '\u003Cspan style=\'color:#ff0000;\'\u003Eerror.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidMonth, error.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidMonth\u003C\/span\u003E',
callback: function(value, validator, $field) {
if(value && $('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day').val() && $('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year').val()){
var currentDate = new Date().getTime();
var fieldsDDMMYYYY = new Date(value + "." + $('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day').val() + "." + $('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year').val()).getTime();
if(typeof fieldsDDMMYYYY == "number" && ((fieldsDDMMYYYY > currentDate)||(fieldsDDMMYYYY < currentDate))) {
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year]');
}
}
if (ACC.global.isDateFieldEmpty("registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince")) {
if ($("small[data-fv-for='" + 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]' +"']").attr('data-fv-result') == "INVALID") {
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]');
}
if ($("small[data-fv-for='" + 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year]' +"']").attr('data-fv-result') == "INVALID") {
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year]');
}
$('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month').addClass('date-input-no-confirmation');
return true;
} else {
$('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month').removeClass('date-input-no-confirmation');
}
if ($field.val().match("^\\d+$") == null){
return false;
}
var value = parseInt($field.val());
if ($('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day').val() != "") {
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]');
}
return value >= 1 && value <= 12;
}
}
}
},
'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year]': {
err: "#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince-date-error-messages",
excluded: false,
trigger: 'blur',
validators: {
callback: {
message: '\u003Cspan style=\'color:#ff0000;\'\u003Eerror.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidYear, error.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidYear\u003C\/span\u003E',
message_en: '\u003Cspan style=\'color:#ff0000;\'\u003Eerror.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidYear, error.genericConfigurableForm.loyaltyMembershipCardValidSince.noValidYear\u003C\/span\u003E',
callback: function(value, validator, $field) {
var value = $field.val();
var currentDate = new Date().getTime();
var fieldsDDMMYYYY = value ? new Date($('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month').val() + "." + $('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day').val() + "." + value).getTime() : new Date().getTime()+1;
if (ACC.global.isDateFieldEmpty("registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince")) {
if ($("small[data-fv-for='" + 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]' +"']").attr('data-fv-result') == "INVALID") {
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]');
}
if ($("small[data-fv-for='" + 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month]' +"']").attr('data-fv-result') == "INVALID") {
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month]');
}
$('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year').addClass('date-input-no-confirmation');
return true;
} else {
$('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year').removeClass('date-input-no-confirmation');
}
if($('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month').val() && value && $('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day').val()){
if(typeof fieldsDDMMYYYY == "number" && (fieldsDDMMYYYY > currentDate)) {
return false;
} else if (typeof fieldsDDMMYYYY == "number" && (fieldsDDMMYYYY < currentDate)) {
return true;
}
}
if (!ACC.global.isValidYear("registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince")) {
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]');
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month]');
$('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year').removeClass('date-input-no-confirmation');
return false;
}
if (value.match("^\\d{4}$") != null) {
if ($('#registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day').val() != "") {
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]');
}
return true;
}
return false;
}
}
}
},
'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince]': {
trigger: 'blur',
validators: {
/**
* Validating date field with custom format when given only month/year using the callback validator and momentjs to parse/validate,
* since OOTB (form validation framework) attribute "format" of the object "date" does not support custom format validation like month/year.
* More info: https://old.formvalidation.io/validators/date/#custom-format-example
*/
callback: {
message: 'Please enter a valid date.',
message_en: 'Please enter a valid date.',
callback: function (value, validator) {
var dateFormat = 'MM.YYYY';
if (!dateFormat) {
return false;
}
var dateObjectCurrent = moment(value, dateFormat);
var minDate = moment('10.1974', dateFormat)
if (dateObjectCurrent.isBefore(minDate)) {
return false;
}
var maxDate = moment('10.2024', dateFormat)
if (dateObjectCurrent.isAfter(maxDate)) {
return false;
}
var strictMode = true; // indicates that strict mode should be applied to parse the date string
return moment(value, dateFormat, strictMode).isValid();
}
},
callbackDate: {
alias: 'callback',
callback: function(value, validator, $field) {
/** The day/month/year fields are hidden in the UI and are populated in JS, by splitting the date field.
The change in the fields is not detected in the validation framework and it requires to manually call
the revalidation after each change of the date field. Otherwise, the fields will remain in an invalid state
and the form validation will fail (preventing the form submission).
*/
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]');
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month]');
$('.js-fr-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year]');
return true;
}
},
}
}
}
}
)
.on('success.field.fv', function() {
/* note: we need to check if there is an error in the form, as the plugin does a validation on field level.
Validating the whole form on blur of a field is no option, as the customer does not want to see error messages on all fields
when entering one field. In case of an error on at least one field we disable the submit button manually */
var $form = $(this).closest('form');
if ($form.find('.form-group.has-error').length > 0) {
var $button = $form.find('.js-button');
if (!$button.hasClass('disabled')) {
$button.addClass('disabled');
}
}
})
.on('err.field.fv', function(e, data) {
/*
* On error field validation, enable submit button.
* Source: https://old.formvalidation.io/examples/enabling-submit-button/
*/
data.fv.disableSubmitButtons(false);
if(data.element.closest('.form-combo-molecule').length){
/* Get the messages of field */
var messages = data.fv.getMessages(data.element);
/* Get the error message content of the field */
var errorContent = data.element.closest('.form-combo-molecule').find('.errors');
/* Get the hidden error message of the field */
var errorField = errorContent.find('.swa-form-input__error-message[data-field="' + data.field + '"][style="display: none;"]');
/* Loop over the messages */
for (var i in messages) {
if (errorField[1] == undefined) {
var newErrorContainer = document.createElement("small");
$(newErrorContainer).attr("class", "swa-form-input__error-message swa-headline-sans--supertiny");
$(newErrorContainer).attr("data-field", data.field);
$(newErrorContainer).attr("data-fv-validator", "callback");
$(newErrorContainer).attr("data-fv-for", $(data.element[0]).attr("name") );
$(newErrorContainer).attr("data-fv-result", "INVALID");
$(newErrorContainer).attr("data-tracked", "true");
$(newErrorContainer).html(messages[i]);
if (errorContent.text().includes(messages[i])) {
$(newErrorContainer).hide();
}
errorContent.append(newErrorContainer);
}
}
}
})
.on('success.field.fv', function(e, data) {
/*
* On success field validation, enable submit button.
* Source: https://old.formvalidation.io/examples/enabling-submit-button/
*/
data.fv.disableSubmitButtons(false);
/* Remove the field messages */
$errorContent = data.element.closest('.form-combo-molecule').find('.errors');
$errorContent.find('.swa-form-input__error-message[data-field="' + data.field + '"]').remove();
$errorContent.find('.swa-form-input__error-message[data-fv-result="INVALID"]').removeAttr("style");
})
.on('success.form.fv', function() {
var formId = 'registerWithScsOfflineMember';
if (!formId || formId === 'cfRequest' || formId === 'cfResponse') {
formId = 'registerWithScsOfflineMemberFormDefinition';
}
ACC.tracking.pushFormSubmit(formId);
});
var replaceDatePatternWithValue = function(mandatory, fieldConfigCode, fieldConfigPattern) {
var date = fieldConfigPattern.toUpperCase();
var year = $("#" + fieldConfigCode + "_year").val();
var month = $("#" + fieldConfigCode + "_month").val();
var day = $("#" + fieldConfigCode + "_day").val();
date = date.replace(/[Y]+/, year);
date = date.replace(/[M]+/, month);
date = date.replace(/[D]+/, day);
var hiddenDateField = $('.js-' + fieldConfigCode + '_hidden');
if (mandatory) {
hiddenDateField.val(date);
} else {
hiddenDateField.val(date == "" ? "" : date);
}
};
var triggerFormValidation = function(fieldId, mandatory, fieldCode, dateFormat) {
replaceDatePatternWithValue(mandatory, fieldCode, dateFormat);
$('.js-fieldCode').formValidation('revalidateField', 'values[fieldCode_'+ fieldId + ']');
};
var removeDateMoleculeError = function(molecule) {
if(molecule.hasClass('has-error')){
molecule.removeClass('has-error');
molecule.find('.help-block').find('span').remove();
}
};
$('.js-registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day').blur(function() {
removeDateMoleculeError($('.js-registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince').closest('.form-combo-molecule'));
triggerFormValidation("day", false, "registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince", "MM.yyyy");
});
$('.js-registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month').blur(function() {
removeDateMoleculeError($('.js-registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince').closest('.form-combo-molecule'));
triggerFormValidation("month", false, "registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince", "MM.yyyy");
});
$('.js-registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year').blur(function() {
removeDateMoleculeError($('.js-registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince').closest('.form-combo-molecule'));
triggerFormValidation("year", false, "registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince", "MM.yyyy");
});
$(this).closest('#scRegisterWithMembershipNumberFormDefinitionWrapper').find('.js-scRegisterWithMembershipNumberFormDefinition')
.formValidation(
{
autoFocus: false,
framework: 'bootstrap',
icon: {
valid: null,
invalid: null,
validating: null
},
fields: {
'values[scRegisterWithMembershipNumberFormDefinition_membershipNumber]': {
trigger: 'blur',
validators: {
callback: {
callback: function(value, validator, $field) {
var messages = [];
var messagesEN = [];
var errorOccured = false;
if ($field.attr('regexCheckDisabled') === 'true') {
return true;
}
if (!value.trim().match(new RegExp('^[0-9]*$', ''))) {
messages.push('Please enter numeric value');
messagesEN.push('Please enter numeric value');
errorOccured |= true;
}
if (errorOccured) {
return {
valid: false,
message: messages.join('<br/>'),
message_en: messagesEN
}
} else {
return true;
}
}
},
notEmpty: {
message: 'Please enter a membership number.',
message_en: 'Please enter a membership number.'
},
stringLength: {
message: 'The number of characters for this field must be between 0 and 11',
message_en: 'The number of characters for this field must be between 0 and 11',
min: 0
,
max: 11
},
}
},
'values[scRegisterWithMembershipNumberFormDefinition_email]': {
trigger: 'blur',
validators: {
regexp: {
regexp: new RegExp('^(?=.{0,255}$)(?=.{0,64}@)(?:(?!^\\.)(?!.*\\.@)(?!.*\\.\\.)[a-zA-Z0-9!#.$%&\'*+\/=?^_‘{|}~-]+|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f]){1,62}\")@(?!-)(?!.*\\.-)(?!.*-\\.)(?:[a-zA-Z0-9-]{1,61}\\.){1,126}(?=[a-zA-Z0-9-]*[a-zA-Z][a-zA-Z0-9-]*$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$', ''),
message: 'Please enter your email address.',
message_en: 'Please enter your email address.'
},
notEmpty: {
message: 'Please enter your email address.',
message_en: 'Please enter your email address.'
},
}
},
'values[scRegisterWithMembershipNumberFormDefinition_password]': {
trigger: 'blur',
validators: {
callback: {
callback: function(value, validator, $field) {
var messages = [];
var messagesEN = [];
var errorOccured = false;
if ($field.attr('regexCheckDisabled') === 'true') {
return true;
}
if (!value.match(new RegExp('(^$|^(?=.*[0-9])(?=.*[A-Z]).{7,}$)', ''))) {
messages.push('The password must be at least 7 characters long and contain a number and a capital letter.');
messagesEN.push('The password must be at least 7 characters long and contain a number and a capital letter.');
errorOccured |= true;
}
if (errorOccured) {
return {
valid: false,
message: messages.join('<br/>'),
message_en: messagesEN
}
} else {
return true;
}
}
},
notEmpty: {
message: 'Please enter a password.',
message_en: 'Please enter a password.'
},
stringLength: {
message: 'You have exceeded the maximum length of 64 characters for this field',
message_en: 'You have exceeded the maximum length of 64 characters for this field',
max: 64
},
}
}
}
}
)
.on('success.field.fv', function() {
/* note: we need to check if there is an error in the form, as the plugin does a validation on field level.
Validating the whole form on blur of a field is no option, as the customer does not want to see error messages on all fields
when entering one field. In case of an error on at least one field we disable the submit button manually */
var $form = $(this).closest('form');
if ($form.find('.form-group.has-error').length > 0) {
var $button = $form.find('.js-button');
if (!$button.hasClass('disabled')) {
$button.addClass('disabled');
}
}
})
.on('err.field.fv', function(e, data) {
/*
* On error field validation, enable submit button.
* Source: https://old.formvalidation.io/examples/enabling-submit-button/
*/
data.fv.disableSubmitButtons(false);
if(data.element.closest('.form-combo-molecule').length){
/* Get the messages of field */
var messages = data.fv.getMessages(data.element);
/* Get the error message content of the field */
var errorContent = data.element.closest('.form-combo-molecule').find('.errors');
/* Get the hidden error message of the field */
var errorField = errorContent.find('.swa-form-input__error-message[data-field="' + data.field + '"][style="display: none;"]');
/* Loop over the messages */
for (var i in messages) {
if (errorField[1] == undefined) {
var newErrorContainer = document.createElement("small");
$(newErrorContainer).attr("class", "swa-form-input__error-message swa-headline-sans--supertiny");
$(newErrorContainer).attr("data-field", data.field);
$(newErrorContainer).attr("data-fv-validator", "callback");
$(newErrorContainer).attr("data-fv-for", $(data.element[0]).attr("name") );
$(newErrorContainer).attr("data-fv-result", "INVALID");
$(newErrorContainer).attr("data-tracked", "true");
$(newErrorContainer).html(messages[i]);
if (errorContent.text().includes(messages[i])) {
$(newErrorContainer).hide();
}
errorContent.append(newErrorContainer);
}
}
}
})
.on('success.field.fv', function(e, data) {
/*
* On success field validation, enable submit button.
* Source: https://old.formvalidation.io/examples/enabling-submit-button/
*/
data.fv.disableSubmitButtons(false);
/* Remove the field messages */
$errorContent = data.element.closest('.form-combo-molecule').find('.errors');
$errorContent.find('.swa-form-input__error-message[data-field="' + data.field + '"]').remove();
$errorContent.find('.swa-form-input__error-message[data-fv-result="INVALID"]').removeAttr("style");
})
.on('success.form.fv', function() {
var formId = 'registerWithMembershipNumber';
if (!formId || formId === 'cfRequest' || formId === 'cfResponse') {
formId = 'scRegisterWithMembershipNumberFormDefinition';
}
ACC.tracking.pushFormSubmit(formId);
});
var replaceDatePatternWithValue = function(mandatory, fieldConfigCode, fieldConfigPattern) {
var date = fieldConfigPattern.toUpperCase();
var year = $("#" + fieldConfigCode + "_year").val();
var month = $("#" + fieldConfigCode + "_month").val();
var day = $("#" + fieldConfigCode + "_day").val();
date = date.replace(/[Y]+/, year);
date = date.replace(/[M]+/, month);
date = date.replace(/[D]+/, day);
var hiddenDateField = $('.js-' + fieldConfigCode + '_hidden');
if (mandatory) {
hiddenDateField.val(date);
} else {
hiddenDateField.val(date == "" ? "" : date);
}
};
var triggerFormValidation = function(fieldId, mandatory, fieldCode, dateFormat) {
replaceDatePatternWithValue(mandatory, fieldCode, dateFormat);
$('.js-fieldCode').formValidation('revalidateField', 'values[fieldCode_'+ fieldId + ']');
};
var removeDateMoleculeError = function(molecule) {
if(molecule.hasClass('has-error')){
molecule.removeClass('has-error');
molecule.find('.help-block').find('span').remove();
}
};
Receive 10% off* your next purchase on swarovski.com (This offer is valid only on full-price items, the voucher code will be provided within one hour after the subscription. The voucher code is valid for 1 month.)
Stay on top of trends and new
collection drops
Invitations to sale events
Faster checkout and wishlist