@immdipu
Posted
its awesome. you can make it more better by adding a clear button to clear the input.
@felipestefani
Posted
@immdipu it's really true!
To UX, this clear button could make a great difference! Thank you for the tip! π«
Hey, guys!
Once more, I did the project vue based to fix code contents. This was a simple layout project, but the data calculation is very tough!
I did a lot of research to learn and to implement my solution.
I hope that you all like it, and, like always, if someone have any tips or opinion to give, I'll be pleased!!
Thank you!
If you wanna know me better, this is my instagram: @felipestefani
@immdipu
Posted
its awesome. you can make it more better by adding a clear button to clear the input.
@felipestefani
Posted
@immdipu it's really true!
To UX, this clear button could make a great difference! Thank you for the tip! π«
@UmerAsad2077
Posted
amazing, how did you make it so that the next input gains focus as soon as the previous one is filled?
@felipestefani
Posted
@UmerAsad2077 How are you? π
I added an id to each input and a listener as well that is called every time any key is pressed (key up).
The verification does:
For example (I did it in Vue, ok?! JS vanilla or react isn't much different):
the code bellow, represents my day and month input, with the id="day" and id="month", respectively
<input :class="{error: dayError}" id="day" type="text" pattern="\d*" placeholder="DD" maxlength="2" v-model="day" @keyup="checkDaySize">
<input :class="{error: monthError}" id="month" type="text" placeholder="MM" maxlength="2" v-model="month" @keyup="checkMonthSize">
every time I click the verification is called, and then, the logic does:
const checkDaySize = () => {
day.value = day.value.replace(/\D/g, '')
day.value.length >= 1 ? dayError.value = '' : ''
day.value.length == 2 ? document.getElementById('month').focus() : ''
}
I don't know if I could explain myself well π ! But if you have any doubts yet, just tell me and I try to say another way βΊοΈ
@UmerAsad2077
Posted
@felipestefani i really appreciate that you took the time to reply, this was extremely helpful π
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord