jquery datepicker throwing error in different browsers with mvc

Viewed 330

my view to display date from database

<div class="input-group">
    @Html.TextBoxFor(model => model.domain_renew_date, "{0:dd/MMM/yyyy}", new { @type = "datetime", @class = "form-control" })
    @Html.ValidationMessageFor(model => model.domain_renew_date, "", new { @class = "text-danger" })
</div>

my javascript for datepicker

 <script type="text/javascript">
    $(document).ready(function () {
        $('input[type="datetime"]').datepicker({
            dateFormat: "dd/MM/yy",
            changeMonth: true,
            changeYear: true,
            yearRange: "c-10:c+10"
        });
    });
</script>

model where the property is declared

[Display(Name = "Date of Renewal")]
[DataType(DataType.Date)]
[RequiredIf("domain_flag", "1", ErrorMessage = "Enter Renew Date")]
public DateTime? domain_renew_date { get; set; }

in web.config

<system.web>
  <globalization uiCulture="en" culture="en-GB" />
</system.web>

This is working perfectly fine in chrome and Firefox. But gives the following error in IE and Safari

The field Date of Renewal must be a date

What changes can be done in the code to make it work perfectly fine in all the browsers?

1 Answers
Related