0

I've stuck on the as it seems to be a simple problem, I got 2 inputs next to each other, one for the hours and 2nd for the minutes, what I want to achive is to get allowed user to type in a current time like for example: right now is 16:20PM so user can type it in, but if he type in a 16:19PM he will get hmmmm in the some hidden label under the inputs that the time is past and he cannot enter it, and all of this have to be checked when she/he set this values without leaving the inputs, so I have no clue how to achive it.

I've found that some1 already tried that but in 'YYYY-MM-DD' format and i need to get hour and minutes only.

I'm gonna be very thankful for any help with that.

1 Answers1

0

One simple thing i would see would be to bind yourself to the (input) event on both your input boxes. Both can call the same function. This function would be fairly simple

See this stackblitz https://stackblitz.com/edit/angular-q69p4j?file=src%2Fapp%2Fapp.component.ts

Alternatively, reactive forms with custom Validators would do the trick as well :)

In this example i didn't manage the AM/PM but that is fairly simple date manipulation. If you need to do more advanced date manipulation you could use a library like momentJS.

https://momentjs.com/

Hope this helps. I'm not sure if I got the full grasp but it should from what I understood.

Good luck