The tool you're looking for is called Regular Expressions.
It is globally supported in almost every development platform, which makes it extremely convenient to use.
I would recommend this website for working out your regular expressions.
/^[a-zA-Z]{2}:[a-zA-Z]{2}&/g is an example of a Regular Expression that will take any pattern of:
[a-zA-Z]{2} - two characters from the sets a-z and A-Z.
Followed by :
Followed by the same first argument. Essentially, validating the pattern XX:XX. Of course, you can manipulate it as to what you want to allow for X.
^ marks the beginning of a string and $ marks the end of it, so ASD:AS would not work even though it contains the described pattern.
hh:mmformat. It's the iso standard format and best for saving in databases and such. it's also what you get when you stringify a Date to json. The view is responsible to display it as the client pleases. One good thing that handle it is the time input that requires the format to be hh:mm but can display differently if they want to see 12h format. 24h is what you would always get if you post a form with a time input, even if it's displayed as 12h with am/pm