>>>>The problem is that I can type any garbage text in the date field. The date is not saved in this case, but I'd rather have it automatic validation for valid date format. I know there is HTML 5 date type, but it doesn't work in our situation as this directive should work for both date and datetime and also it has its own date picker which is called from an extra button.
>>>>
>>>>So, do you know what can be done to make sure the input is correct date?
>>>
>>>You probably a directive with custom validation - there's an example in the 'Custom Validation' section here :
>>>
https://docs.angularjs.org/guide/forms>>
>>Great, thanks a lot. Hope I (or someone) will be able to work it out.
>
>Pretty straightforward.
>ctrl.$parsers.unshift adds the function to the beginning of the pipeline that will be called when control content changes.
>In the function you just need to do the ctrl.$setValidity true/false.
Thanks a lot again.
If it's not broken, fix it until it is.
My Blog