php - Visual Studio 2017 Movierental 日期设置
问题描述
我有一个电影租赁应用程序,它基于就像在电影院订票但它需要特定的场景
“示例毒液:让大屠杀于 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>
解决方案
In POST Action, you can compare the date.
[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();
}
推荐阅读
- azure - Azure SignalR 无服务器和 dotnet 核心 API 应用程序
- python - 如何向不同设置的用户发送不同的消息?不和谐.py
- excel - 对表进行排序,使 1 个值(状态)始终位于最后,同时仍按第二个值(时间)排序
- javascript - 赛普拉斯断言失败但测试通过
- python - 在 Python 中使用 Pandas 删除括号 () 和后处理数据帧的问题
- sql - 如何检查列的值是否像另一列的值一样开始
- javascript - 将数组值推送到对象
- node.js - 相同的 node.js 后端服务,对于来自不同客户端的相同请求的行为不同
- wordpress - 使用“woocommerce_product_get_tax_class”挂钩时,“WC()->cart->get_subtotal()”返回 0
- amazon-web-services - 未找到 stepfunction 时将状态码从 200 更改为 404