mvc中的日期拾取器验证

Datepickers validations in mvc

本文关键字:验证 日期 mvc      更新时间:2023-09-26

我有开始日期和结束日期,开始日期应该大于结束日期。

我有两个日期选择器折扣开始日期和折扣结束日期。

折扣开始日期应小于开始日期,折扣结束日期应小于结束日期。如何在Javascript或jQuery中编写验证?

您没有提供任何关于日期格式的信息无论如何,逻辑总是一样的,比如:

var date,endDate,dateDiscount,endDateDiscount;
if ((date<=endDate) || (dateDiscount>=date) || (endDateDiscount>=endDate)) alert('error! dates not good')

解释:

(date<=endDate) //the reverse of "start date should be greater than end date"
(dateDiscount>=date) //the reverse of "discount start date should be less than start date"
(endDateDiscount>=endDate) // the reverse of "discount end date should be less than end date "