// Form validation $("input").blur(function () { var usernameError = false, birthdateError = false, emailError = false, passwordError = false, passwordRepeatError = false; // Username if ($(this).attr('name') === "username") { if ($(this).val().length < 4) { $('#usernameErrorLength').addClass('active'); usernameError = true; } else { $('#usernameErrorLength').removeClass('active'); usernameError = false; } // if($(this).val()) } }); $('#language').selectize(); $('#country').selectize(); const monthDayCounts = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; $('#birthdate-month').change(function () { updateDaySelection(); }); $('#birthdate-year').change(function () { if(parseInt($('#birthdate-year').val()) % 4 === 0 && $('#birthdate-month').val() === 2) { updateDaySelection(29); } }); function updateMonthSelection() { const defaultMonth = parseInt($('#birthdate-month').attr('data-default')) || 0; console.log(defaultMonth); $('#birthdate-month option').eq(defaultMonth).attr('selected', 'selected'); } function updateDaySelection() { const dayCount = monthDayCounts[parseInt($('#birthdate-month').val()) - 1] || 31; $('#birthdate-day').empty().append(''); for (let i = 1; i <= dayCount; i++) { $('#birthdate-day').append(''); } const defaultDay = parseInt($('#birthdate-day').attr('data-default')) || 0; console.log(defaultDay); $('#birthdate-day option').eq(defaultDay).attr('selected', 'selected'); } function updateYearSelection() { const curYear = new Date().getFullYear(); for(let i = curYear; i >= curYear - 120; i--) { $('#birthdate-year').append(''); } } updateMonthSelection(); updateDaySelection(); updateYearSelection();