简体   繁体   English

时间和日期选择器 type='datetime-local'

[英]Time and Date picker type='datetime-local'

I have two text-field html elements to pick start and end date/time respectively.我有两个文本字段 html 元素分别选择开始结束日期/时间。 How to make start date/time less than end date/time?如何使开始日期/时间小于结束日期/时间?

<v-text-field
  id="setTime"
  outlined
  type="datetime-local"
  label="Start time"
  v-model="plan.start"
>
</v-text-field>

first, disable end date/time conditional if there is no start date/time it must be disabled.首先,如果没有开始日期/时间,则必须禁用结束日期/时间条件。 after that when user select start date/time then on validation check if end date/time is lessThan start date/time return error, also, you can disable days lessThan start day/time in end date/time field (read your date/time picker library document)之后,当用户 select 开始日期/时间然后在验证检查结束日期/时间是否小于开始日期/时间返回错误时,您也可以在结束日期/时间字段中禁用小于开始日期/时间的天数(阅读您的日期/时间选择器库文档)

you can use yup for validation date-time or do it manually:您可以使用 yup 验证日期时间或手动进行:

if your date/time is in epoch format it's like this如果您的日期/时间是纪元格式,就像这样

const schema = yup.object({
  fromDate: yup.number().required(),
  toDate: yup.number().moreThan(yup.ref("fromDate")).required(),
});

I hope it help you希望对你有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HTML 表格与 javascript 日期选择器(本地日期时间)未响应所需 - HTML Form with javascript date picker (datetime-local) not responding to required React JSX 将最小日期时间添加到 datetime-local 输入 - React JSX add min date time to datetime-local input 在日期时间本地输入中单击当前日期和时间 - Onclick current date and time in datetime-local input 如何删除datetime-local输入类型中的时间值? - How to remove time value in datetime-local input type? <input type="datetime-local" />没有按预期显示时间 - <input type="datetime-local" /> not displaying the TIME as expected 如何将 datetime-local 类型的输入控件设置为当前时间 - How to set the input control of type datetime-local to the current time 如何在 material-ui 中为当前日期和时间的文本字段类型 datetime-local 设置默认值? - how can I set the default value to the textfield type datetime-local in material-ui for the current date and time? 在 html 输入日期时间本地选择器中禁用上一个今天的上一个时间 - Disable previous today's previous time in html input datetime-local picker 如何将 HTML 日期时间选择器 datetime-local 转换为时刻格式 - How to transfer HTML datetime picker datetime-local to moment format 从 Date 设置 datetime-local 的值 - Setting value of datetime-local from Date
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM