Date validation plugin for JustValidate library
npm install just-validate-plugin-date --save
yarn add just-validate-plugin-date
And then use it as an imported module:
import JustValidatePluginDate from 'just-validate-plugin-date';
Or if you don't use module bundlers, just include JustValidatePluginDate script on your page from CDN and call it as window.JustValidatePluginDate
:
<script src="https://unpkg.com/browse/just-validate-plugin-date@1.2.0/dist/just-validate-plugin-date.production.min.js"></script>
This plugin is supposed to use together with JustValidate library. It takes 1 argument: function which returns the validation config.
Check more details and examples here: https://github.com/horprogs/Just-validate
JustValidatePluginDate((fields) => ({
required: true,
format: 'dd/MM/yyyy',
isAfter: fields['#date_after'].elem.value,
isBefore: fields['#date_before'].elem.value,
}));
import JustValidatePluginDate from 'just-validate-plugin-date';
validator.addField('#date', [
{
plugin: JustValidatePluginDate((fields) => ({
format: 'dd/MM/yyyy',
isAfter: '',
})),
},
]);
- isAfter
- isBefore
- isBeforeOrEqual
- isAfterOrEqual
- isEqual