我有一个电影应用程序,它的基础是电影院的门票预订,但它需要特定的场景
“示例毒液:让大屠杀在2021年6月25日发布”
我的目标是让它不能“在电影上映日期前预订门票
这是我的代码。
<div class="form-group">
@Html.LabelFor(model => model.Schedule, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
<input type="date" name="Schedule" required />
</div>
</div>发布于 2020-12-15 11:58:47
在POST Action中,您可以比较日期。
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Index(MyModel My)
{
if (ModelState.IsValid)
{
if (My.Schedule > DateTime.Today)
{
ModelState.AddModelError(string.Empty, "Movie has not released yet.");
return View();
}
//Otherwise do further process here
}
return View();
}https://stackoverflow.com/questions/65283626
复制相似问题