So, It's not the first time I ask that kind of question but it's still not working...
I've put a date picker like this :
<script>
$(document).ready(function () {
$('.date').datepicker({ dateFormat: "dd/mm/yy", firstDay: 1 });
});
</script>
And I call it this way :
@Html.TextBox("date", null, new { @class = "date", @Value = DateTime.Today.Date })
The problem is : as you see I'd like to have a dd/mm/yy
format and that's the case when I select a date, it's in dd/mm/yy
but when I push the submit button, it's not going to the controller and the datepicker shows up like to say : "Hey you made a mistake, I want a mm/dd/yy
format"...
I've tried to remove the client side validation with @{ Html.EnableClientValidation(false); }
but it doesn't change anything....
Can please someone help me ? Thanks in advance !
EDIT : Like I said, maybe not clearly enought, the problem is not coming from the server but from the client ! I have disable client validation in my web.config and it's now working
答案 0 :(得分:0)
模型中Date
属性的属性是什么样的?不久前我遇到了类似于你的问题。您想调试并确定当前系统日期格式是什么。
您可以尝试在.datepicker
函数中插入一个简单的函数,如下所示:
$(".date").datepicker({
dateFormat: "dd-mm-yy",
onSelect: function () {
var selectedDate = $('#the-id-of-my-datepicker-goes-here').datepicker('getDate');
console.log("The current selected date is: " + selectedDate); //alternatively alert(selectedDate);
}
})