Appearance
FormPickerDatetimerange
Datepicker a wyborem daty początkowej i końcowej, oraz wskazaniem czasu dla dat.
format
Format of the date
type:
String
default:
YYYY-MM-DD
size
Input size
type:
String
default:
md
values:
sm, md, lg
twelve
WWhether the time is to be 12-hours format
type:
Boolean
default:
false
hoursText
Text describing the column with hours
type:
String
default:
Hours
minutesText
Text describing a column with minutes
type:
String
default:
Minutes
step
Defines the ranges of minutes
type:
Number
default:
5
values:
1, 2, 3, 4, 5, 6, 10, 15, 20, 30
Examples
Datepicker with validation, 12-hours format
-
- The start date is: Invalid Date
- The end date is: Invalid Date
html
<form-field name="date" :model="date">
<form-label text="Your date:" />
<form-picker-datetimerange twelve format="DD-MM, hh:mm A" />
<form-valid success="This is a great date" />
</form-field>
ts
import { computed } from 'vue'
import { useField, useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/zod'
import * as zod from 'zod'
import dayjs from 'dayjs'
const { handleSubmit } = useForm()
const onSubmit = handleSubmit()
const fieldSchema = toTypedSchema(
zod
.string({
required_error: 'This date is required',
invalid_type_error: 'This is not a good date'
})
.datetime({ offset: true, message: 'Incorrect format' })
)
const date = useField('date')
useField('date.from', fieldSchema, { initialValue: '' })
useField(
'date.to',
toTypedSchema(
zod
.string({
required_error: 'The end date is required',
invalid_type_error: 'This is not a good end date'
})
.datetime({ offset: true, message: 'Incorrect format of the end date' })
),
{ initialValue: '' }
)
const dateFromForPrint = computed(() => dayjs(date.value.value.from).format())
const dateToForPrint = computed(() => dayjs(date.value.value.to).format())
DatePicker with validation with defined dates
-
- The start date is: 2023-05-12T22:01:53+00:00
- The end date is: 2023-05-16T22:01:53+00:00
html
<form-field name="daterange" :model="daterange">
<form-label text="Your date:" />
<form-picker-datetimerange />
<form-valid success="This is a great date" />
</form-field>
ts
import { computed } from 'vue'
import { useField, useForm } from 'vee-validate'
import { toTypedSchema } from '@vee-validate/zod'
import * as zod from 'zod'
import dayjs from 'dayjs'
const { handleSubmit } = useForm()
const onSubmit = handleSubmit()
const fieldSchema = toTypedSchema(
zod
.string({
required_error: 'This date is required',
invalid_type_error: 'This is not a good date'
})
.datetime({ offset: true, message: 'Incorrect format' })
)
const daterange = useField('daterange')
useField('daterange.from', fieldSchema, { initialValue: '2023-05-13T00:01:53+02:00' })
useField(
'daterange.to',
toTypedSchema(
zod
.string({
required_error: 'The end date is required',
invalid_type_error: 'This is not a good end date'
})
.datetime({ offset: true, message: 'Incorrect format of the end date' })
),
{ initialValue: '2023-05-17T00:01:53+02:00' }
)
const daterangeFromForPrint = computed(() => dayjs(daterange.value.value.from).format())
const daterangeToForPrint = computed(() => dayjs(daterange.value.value.to).format())