Time range in Vue Timepicker component
11 Jun 20243 minutes to read
TimePicker provides an option to select a time value within a specified range by using the min
and max
properties. The min value should always be lesser than the max value.
When the min and max properties are configured and the selected time value is out-of-range or invalid, then the model value will be set to out of range
time value or null
respectively with highlighted error
class to indicates the time is out of range or invalid.
The value property depends on the min/max with respect to strictMode
property.
The following example allows you to select a time value within a range of 9:00 AM
to 11:30 AM
.
<template>
<div id="app">
<div class='wrap'>
<ejs-timepicker id='timepicker' :value='timeval' :min='minTime' :max='maxTime'></ejs-timepicker>
</div>
</div>
</template>
<script setup>
import { TimePickerComponent as EjsTimepicker } from "@syncfusion/ej2-vue-calendars";
const timeval = new Date('3/8/2017 11:00 AM');
const minTime = new Date('3/8/2017 9:00 AM');
const maxTime = new Date('3/8/2017 11:30 AM');
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
@import '../node_modules/@syncfusion/ej2-lists/styles/material.css';
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material.css";
.wrap {
margin: 35px auto;
width: 240px;
}
</style>
<template>
<div id="app">
<div class='wrap'>
<ejs-timepicker id='timepicker' :value='timeval' :min='minTime' :max='maxTime'></ejs-timepicker>
</div>
</div>
</template>
<script>
import { TimePickerComponent } from "@syncfusion/ej2-vue-calendars";
export default {
name: "App",
components: {
"ejs-timepicker": TimePickerComponent
},
data() {
return {
timeval: new Date('3/8/2017 11:00 AM'),
minTime: new Date('3/8/2017 9:00 AM'),
maxTime: new Date('3/8/2017 11:30 AM')
}
}
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
@import '../node_modules/@syncfusion/ej2-lists/styles/material.css';
@import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material.css";
.wrap {
margin: 35px auto;
width: 240px;
}
</style>
If the value of
min
ormax
property is changed through code behind you have to update thevalue
property to set within the range.