Suscríbete al Newsletter

Acepto los Términos y Condiciones / Políticas de privacidad

Sí, quiero recibir comunicaciones de Redken sobre novedades, productos y servicios

Suscríbete al Newsletter

Acepto los Términos y Condiciones / Políticas de privacidad

Sí, quiero recibir comunicaciones de Redken sobre novedades, productos y servicios

<script>
jQuery(function() {
var currentSelectedYear, currentSelectedMonth,currentSelectedDay,today = new Date(), month = today.getMonth()+1, day = today.getDate(),
DayId=jQuery(".CustomDateSelector").find("select").length > 0 ? jQuery(".CustomDateSelector").find("select")[0].id:"",
MonthId=jQuery(".CustomDateSelector ").find("select").length > 1 ? jQuery(".CustomDateSelector").find("select")[1].id : "",
YearId=jQuery(".CustomDateSelector").find("select").length > 2 ? jQuery(".CustomDateSelector").find("select")[2].id : "", AgeLimit=18;

/* To update the fields In Initial Load */
function UpdateDateField(load,source)
{
SetCurrentSelectedFieldValue();
var SetMonth= CheckYearDifference() || load=="onload" ? month:12;
if(source=="month" || source=="all"){ UpdateMonthField(SetMonth); }
setTimeout(function(){
currentSelectedMonth=jQuery("#"+MonthId).val();
var SetDay= (CheckYearDifference() && currentSelectedMonth == month) || load=="onload" ? day : daysInMonth(currentSelectedMonth,currentSelectedYear);
if(source=="day" || source=="all") { UpdateDayField(SetDay); }
},10)
}

/* To Set the Current Selected field values */
function SetCurrentSelectedFieldValue(){
currentSelectedMonth=jQuery("#"+MonthId).val();
currentSelectedYear=jQuery("#"+YearId).val();
}

/* Function to Check and return difference of selected Year and Current Year */
function CheckYearDifference(){
return today.getFullYear() - parseInt(currentSelectedYear) <= AgeLimit ? true : false;
}

/* Function to Check and return difference of selected Day and Old Day */
function CheckDayDifference(){
return currentSelectedDay > daysInMonth(jQuery("#"+MonthId).val(),jQuery("#"+YearId).val()) ? true : false;
}

/* To update Month field when change option*/
function UpdateMonthField(months){
jQuery("#"+MonthId).find("option").remove();
var monthdict={"1":"Jan","2":"Feb","3":"Mar","4":"Apr","5":"May","6":"Jun","7":"Jul","8":"Aug","9":"Sep","10":"Oct","11":"Nov","12":"Dec"}
for (var i = 1; i <= months; i++)
{
jQuery("#"+MonthId).append(jQuery('<option/>', { value: i, text: monthdict[i] }));
}
jQuery("#"+MonthId).val(currentSelectedMonth > months? months:currentSelectedMonth)
}

/* To update Day field when change option*/
function UpdateDayField(days){
jQuery("#"+ DayId).find("option").remove();
for (var i = 0; i < days; i++)
{
jQuery("#"+DayId).append(jQuery('<option/>', { value: i + 1, text: i + 1 }));
}
jQuery("#"+DayId).val(currentSelectedDay > days ? days : currentSelectedDay);
}

/* To trigger when change option in Day Field*/
jQuery("#"+ DayId).change(function(){
currentSelectedDay=jQuery("#"+DayId).val();
if(jQuery("#"+DayId).val() != null && CheckDayDifference()){ jQuery("#"+DayId).val("1") } // We need to set 1 or lower number in order to avoid Required message because of some WFFM date functionality
UpdateDateField("change", "day");
});
/* To trigger when change option in Year Field*/
jQuery("#"+ YearId).change(function(){
currentSelectedDay=jQuery("#"+DayId).val();
if(jQuery("#"+DayId).val() != null && CheckDayDifference()){ jQuery("#"+DayId).val("1") } // We need to set 1 or lower number in order to avoid Required message because of some WFFM date functionality
UpdateDateField("change", "all");
});

/* To trigger when change option in Month Field*/
jQuery("#"+ MonthId).change(function(){
currentSelectedDay=jQuery("#"+DayId).val();
if(jQuery("#"+DayId).val() != null && CheckDayDifference()){ jQuery("#"+DayId).val("1") }// We need to set 1 or lower number in order to avoid Required message because of some WFFM date functionality
UpdateDateField("change","day");
});

/* To get the total days o given month*/
function daysInMonth(month, year) {
return new Date(year, month, 0).getDate();
}
jQuery("#"+DayId).val("");jQuery("#"+MonthId).val("");jQuery("#"+YearId).val(""); // Initially empty the date fields
});
</script>