经过几个小时的搜索,我只是用几行代码解决了这个问题
您的模特
[Required(ErrorMessage = "Enter the issued date.")]
[DataType(DataType.Date)]
public DateTime IssueDate { get; set; }
剃刀页
@Html.TextBoxFor(model => model.IssueDate)
@Html.ValidationMessageFor(model => model.IssueDate)
jQuery DatePicker
<script type="text/javascript">
$(document).ready(function () {
$('#IssueDate').datepicker({
dateFormat: "dd/mm/yy",
showStatus: true,
showWeeks: true,
currentText: 'Now',
autoSize: true,
gotoCurrent: true,
showAnim: 'blind',
highlightWeek: true
});
});
</script>
Webconfig文件
<system.web>
<globalization uiCulture="en" culture="en-GB"/>
</system.web>
现在,您的文本框将接受“ dd / MM / yyyy”格式。