Inzajt Inzajt - 1 month ago 6
AngularJS Question

Input-field, force format 00:00.00

I have an input-field that has a value(model) with microseconds(ex. 1950), and a filter that transforms the microseconds to a human readable format, for example 00:19.50(this is displayed in the input-field). How can i validate or force the user to keep this format?

Answer

You can chive this by making use of the pattern attribute which accepts a regular expression.

You can read more about it here: http://www.the-art-of-web.com/html/html5-form-validation/

This is the example they provide.

<input type="url" name="website" required pattern="https?://.+">

I hope this helps.

@gapvision privided you an answer with a correct patter that suit your needs

pattern='\d\d:\d\d.\d\d