¿Te has registrado en una tienda?
Activa tu cuenta en línea introduciendo tus datos de inicio de sesión y el número de suscripción. Luego elige una contraseña.
Selecciona a continuación el tipo de suscripción:
$(this).closest('#us-registerWithScsOfflineMemberFormConfigWrapper').find('.js-us-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('Por favor introduce un número de socio válido con este formato 123-45455');
messagesEN.push('Por favor introduce un número de socio válido con este formato 123-45455');
errorOccured |= true;
}
if (errorOccured) {
return {
valid: false,
message: messages.join('<br/>'),
message_en: messagesEN
}
} else {
return true;
}
}
},
notEmpty: {
message: 'El campo de número de socio no puede estar vacío',
message_en: 'El campo de número de socio no puede estar vacío'
},
stringLength: {
message: 'Este campo debe tener entre 0 y 11 caracteres',
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: 'Por favor introduzca su correo electrónico.',
message_en: 'Por favor introduzca su correo electrónico.'
},
notEmpty: {
message: 'Por favor introduzca su correo electrónico.',
message_en: 'Por favor introduzca su correo electrónico.'
},
stringLength: {
message: 'Este campo debe tener entre 1 y 70 caracteres',
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('La contraseña debe tener al menos 7 caracteres y contener un número y una letra mayúscula.');
messagesEN.push('La contraseña debe tener al menos 7 caracteres y contener un número y una letra mayúscula.');
errorOccured |= true;
}
if (errorOccured) {
return {
valid: false,
message: messages.join('<br/>'),
message_en: messagesEN
}
} else {
return true;
}
}
},
notEmpty: {
message: 'Crea una contraseña.',
message_en: 'Crea una contraseña.'
},
stringLength: {
message: 'Ha excedido la longitud máxima de 64 caracteres en este campo',
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-us-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-us-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month');
}
if ($("small[data-fv-for='" + 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year]' +"']").attr('data-fv-result') == "INVALID") {
$('.js-us-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-us-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-us-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]');
}
if ($("small[data-fv-for='" + 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_year]' +"']").attr('data-fv-result') == "INVALID") {
$('.js-us-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-us-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-us-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]');
}
if ($("small[data-fv-for='" + 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month]' +"']").attr('data-fv-result') == "INVALID") {
$('.js-us-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-us-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]');
$('.js-us-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-us-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: 'Introduce una fecha válida.',
message_en: 'Introduce una fecha válida.',
callback: function (value, validator) {
var dateFormat = 'MM.YYYY';
if (!dateFormat) {
return false;
}
var dateObjectCurrent = moment(value, dateFormat);
var minDate = moment('12.1974', dateFormat)
if (dateObjectCurrent.isBefore(minDate)) {
return false;
}
var maxDate = moment('12.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-us-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_day]');
$('.js-us-registerWithScsOfflineMemberFormConfig').formValidation('revalidateField', 'values[registerWithScsOfflineMemberFormDefinition_loyaltyMembershipCardValidSince_month]');
$('.js-us-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('Introduce un valor numérico');
messagesEN.push('Introduce un valor numérico');
errorOccured |= true;
}
if (errorOccured) {
return {
valid: false,
message: messages.join('<br/>'),
message_en: messagesEN
}
} else {
return true;
}
}
},
notEmpty: {
message: 'Introduce un número de suscripción.',
message_en: 'Introduce un número de suscripción.'
},
stringLength: {
message: 'Este campo debe tener entre 0 y 11 caracteres',
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: 'Por favor introduzca su correo electrónico.',
message_en: 'Por favor introduzca su correo electrónico.'
},
notEmpty: {
message: 'Por favor introduzca su correo electrónico.',
message_en: 'Por favor introduzca su correo electrónico.'
},
}
},
'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('La contraseña debe tener un mínimo de 7 caracteres y contener un número y una letra mayúscula.');
messagesEN.push('La contraseña debe tener un mínimo de 7 caracteres y contener un número y una letra mayúscula.');
errorOccured |= true;
}
if (errorOccured) {
return {
valid: false,
message: messages.join('<br/>'),
message_en: messagesEN
}
} else {
return true;
}
}
},
notEmpty: {
message: 'Introduzca una contraseña.',
message_en: 'Introduzca una contraseña.'
},
stringLength: {
message: 'Ha excedido la longitud máxima de 64 caracteres en este campo',
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();
}
};
Recibe un 10% de descuento* en tu primera compra en swarovski.com
Estate al tanto de las tendencias
y de los nuevos lanzamientos de la colección
Invitaciones a eventos de rebajas
Pago más rápido y lista de deseos