Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 比较asp.net mvc中的两个输入字段_C#_Asp.net Mvc - Fatal编程技术网

C# 比较asp.net mvc中的两个输入字段

C# 比较asp.net mvc中的两个输入字段,c#,asp.net-mvc,C#,Asp.net Mvc,模型类中有两个属性: public DateTime StartDate { get; set; } public DateTime EndDate { get; set; } 此处,StartDate应始终小于EndDate 在asp.net mvc中是否对此有任何数据注释?可以选择编写自己的自定义属性,如中所示 另一个选项是使用(可从Nuget获得) 没有内置属性,但您可以使用的[LessThan]attributedesnt与jQuery日期选择器配合使用。它仅在输入更改时起作用,但选择

模型类中有两个属性:

public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
此处,
StartDate
应始终小于
EndDate

在asp.net mvc中是否对此有任何数据注释?可以选择编写自己的自定义属性,如中所示

另一个选项是使用(可从Nuget获得)


没有内置属性,但您可以使用的
[LessThan]
attributedesnt与jQuery日期选择器配合使用。它仅在输入更改时起作用,但选择器不会导致输入更改事件
public class EventViewModel
{
    [Required]
    public string Name { get; set; }

    [Required]
    public DateTime Start { get; set; }

    [Required]
    [GreaterThan("Start")]
    public DateTime End { get; set; }
}