Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Responsive page using vue

Felipe Stefaniβ€’ 330

@felipestefani

Desktop design screenshot for the Age calculator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


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

Community feedback

Dipuβ€’ 430

@immdipu

Posted

its awesome. you can make it more better by adding a clear button to clear the input.

1

Felipe Stefaniβ€’ 330

@felipestefani

Posted

@immdipu it's really true!

To UX, this clear button could make a great difference! Thank you for the tip! πŸ’«

0
UmerAsadβ€’ 30

@UmerAsad2077

Posted

amazing, how did you make it so that the next input gains focus as soon as the previous one is filled?

1

Felipe Stefaniβ€’ 330

@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:

  • Check the size of the input value when a key is released;
  • if the size of the input is equal 2, then I focus the next input

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:

  • not allow insert any key that isn't a number;
  • remove error, if any; and finally
  • check if the day value length is equal 2, and then focuses the next input (in this case, the input with id="month", else does nothing
 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 ☺️

0
UmerAsadβ€’ 30

@UmerAsad2077

Posted

@felipestefani i really appreciate that you took the time to reply, this was extremely helpful πŸ‘

1

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

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