VeeValidate HH:MM:SS

Posted on March 7, 2018
Written by

In the below example I was using VueJs in Laravel and needed to check that a form input followed the HH:MM:SS format using VeeValidate.

Note : VeeValidate already has a date format validator so if you are looking for that references their documentation here : http://vee-validate.logaretm.com/validation.html#rule-date_format

How to add custom HH:MM:SS validation using VeeValidate

HTML :

 

Here we assign a custom validation type ‘is_time’ as well are making the field required. VeeValidate will then look for a matching ‘is_time’ rule in the validator. Below we extend the validator to add this rule.

VueJS :

Thanks for reading – I hope this was helpful.