Change date format validation, mvc 3 and jQuery

I struggled with this problem for two days and still have not found a solution ... I added a feedap to my website using this tutorial: http://blogs.msdn.com/b/stuartleeks/archive/2011/01/25 /asp-net-mvc-3-integrating-with-the-jquery-ui-date-picker-and-adding-a-jquery-validate-date-range-validator.aspx

Everything works, except for verification. I keep getting the error "Please enter a valid date." I changed everything in my solution to "dd-MM-yyyy" and added a culture of globalization = "da-DK" uiCulture = "da-DK"

in my web.config. I am still working. Keep getting the error. Should I possibly change the model class? Date I want to confirm:

    [DataType(DataType.Date)]
    public DateTime DateOfBooking { get; set; }

Tried using:

    $('#formatdate').change(function () {
        $('#datpicker').datepicker("option", "dateFormat", "dd-mm-yy");
    });

and

$(document).ready(function () {
function getDateYymmdd(value) {
    if (value == null)
        return null;
    return $.datepicker.parseDate("dd-mm-yy", value);
}
$('.date').each(function () {
    var minDate = getDateYymmdd($(this).data("val-rangedate-min"));
    var maxDate = getDateYymmdd($(this).data("val-rangedate-max"));
    $(this).datepicker({
        dateFormat: "dd-mm-yyyy",  // hard-coding uk date format, but could embed this     as an attribute server-side (based on the current culture)
        minDate: minDate,
        maxDate: maxDate
    });
});
});

, . , mvc jquery. -, , :) !

+5
1

jquery.validate, . . , .

+4

All Articles