OK, so this is the high level. I have 3 objects under a data() field
data () {
birth_day: '',
birth_month: '',
birth_year: '',
birthdate: '',
}
I also have a 4th data object called birthdate as you can see above. When a user fills in each item, I want to combine them into birthdate in the format YEAR-MONTH-DAY (for Database storage)
I also, if possible, want to add a 0 if someone types say 3 for March and not 03
I am having an issue wrapping my head around this. This is part of a multi-step registration form.
Any help would be very helpful!
PS for anyone asking - this is the template code:
<div class="flex flex-row justify-between">
<div class="relative border border-gray-500 rounded-md px-3 py-2 shadow-sm focus-within:ring-1 focus-within:ring-red-600 focus-within:border-red-600">
<label for="birth_month" value="birth_month" class="absolute -top-2 left-2 -mt-px inline-block px-1 bg-gray-900 text-sm font-medium text-gray-50">Month</label>
<input minlength="2" maxlength="2" type="text" name="birth_month" id="birth_month" class="bg-gray-900 text-white block w-full border-0 p-0 placeholder-gray-500 focus:ring-0 sm:text-sm" placeholder="02" />
</div>
<div class="relative border border-gray-500 rounded-md px-3 py-2 mx-4 shadow-sm focus-within:ring-1 focus-within:ring-red-600 focus-within:border-red-600">
<label for="birth_day" value="birth_day" class="absolute -top-2 left-2 -mt-px inline-block px-1 bg-gray-900 text-sm font-medium text-gray-50">Day</label>
<input minlength="2" maxlength="2" type="text" name="birth_day" id="birth_day" class="bg-gray-900 text-white block w-full border-0 p-0 placeholder-gray-500 focus:ring-0 sm:text-sm" placeholder="15" />
</div>
<div class="relative border border-gray-500 rounded-md px-3 py-2 shadow-sm focus-within:ring-1 focus-within:ring-red-600 focus-within:border-red-600">
<label for="birth_year" value="birth_year" class="absolute -top-2 left-2 -mt-px inline-block px-1 bg-gray-900 text-sm font-medium text-gray-50">Year</label>
<input minlength="4" maxlength="4" type="text" name="birth_year" id="birth_year" class="bg-gray-900 text-white block w-full border-0 p-0 placeholder-gray-500 focus:ring-0 sm:text-sm" placeholder="2000" />
</div>
</div>
birthdate, you should probably use something likedate-fnsto properly handle this. Otherwise, a computed property should be enough to mix all those 3 together.birthdateas '1999-02-29`? NOTE: 1999 is not a leap year and hence February does not have 29 days.