我有这个“小”问题。 我创建了一个项目MVC,在该项目中我需要使用其他字段注册用户。 (我只会向您展示一部分。) 一个特定的领域给我一个问题: 在字段 DateOfBirth 上,我在 jquery
上实现了日期选择器首先,我得到了之前录制的所有旧数据,并且日历落后了,所以我无法选择日期:
@model WebApplication2.Models.Person
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Person</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.FirstName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.FirstName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.FirstName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.LastName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.LastName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.LastName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DateOfBirth, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DateOfBirth, new { htmlAttributes = new { @class = "datepicker form-control" } })
@Html.ValidationMessageFor(model => model.DateOfBirth, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "ListPerson")
</div>
<link href="~/Content/themes/base/jquery-ui.min.css" rel="stylesheet" />
@section Scripts {
<script src="~/Scripts/jquery-ui-1.12.1.min.js"></script>
@Scripts.Render("~/bundles/jqueryval")
<script>
$(function() {
$(".datepicker").datepicker(
{
dateFormat: "yy/mm/dd",
changeMonth: true,
changeYear : true
});
});
</script>
}
起初,我认为它只是浏览器的缓存,并且我对许多浏览器(IE11,Mozilla,Chrome)进行了测试,然后清除了缓存,但似乎将日期存储在应用程序缓存中。 你知道这可能是什么原因吗?
亲切的问候。
答案 0 :(得分:0)
尝试添加autocomplete =“ off”属性– Stephen Muecke
""" Model for documenting the API"""
insert_user_data = ns_database.model("Insert_user_data",
{
"customer_id":
fields.String(description="cust ID", required=True),
"service_id":
fields.String(description="service ID", required=True),
"customer_name":
fields.String(description="Customer1", required=True),
"site_name":
fields.String(description="site", required=True),
"service_type":
fields.String(description="service", required=True)
}
)
@ns_database.route('/insert_user')
class database(Resource):
@ns_database.expect(insert_user_data)
def post(self):
"""insert data"""
json_data = request.json
customer_id = json_data['customer_id']
service_id = json_data['service_id']
customer_name = json_data['customer_name']
site_name = json_data['site_name']
service_type = json_data['service_type']
它有效:)