The built-in date validator provides a handy tool when we need to validate a date. It supports various formats of date with different separator, such as MM/DD/YYYY or YYYY-MM-DD. But there's only one format supported at the same time.
In some cases, you want the field to accept multiple formats such as DD.MM.YYYY and DD.MM.YY. The first format is supported by date validator, but the second one isn't.
This example shows how to do this by using the callback validator and the momentjs library.
The momentjs library provides isValid() method to check if a date follows by given format:
The third parameter of moment() constructor HAVE to set as true to ensure that the input has the given format exactly