0

I want to add a date time picker in HTML5 using MVC5 , as i created Datatype Date Time in Database.... So how to show Date Time picker??. I tried the following

@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/jqueryui")
@Styles.Render("~/Content/themes/base/css")
@Styles.Render("~/Content/Jcss")

<script src="~/Scripts/jquery-2.1.3.js"></script>
<script src="~/Scripts/jquery.datetimepicker.js"></script>

<script type="text/javascript">
    $(document).ready(function () {
        $("#DeliveryDate").datetimepicker();
    });
</script>

And in HTML

<div class="col-md-6">
    <input type="text" name="DeliveryDate" id="DeliveryDate" />
    @Html.ValidationMessageFor(model => model.DeliveryDate, "", new { @class = "text-danger" })
</div>
Erik Philips
  • 53,428
  • 11
  • 128
  • 150
MMG
  • 151
  • 1
  • 3
  • 13

2 Answers2

0

You can use input type="date" in HTML5 but it's not well supported. current version of Firefox doesn't support it so you likely to have a lot of trouble getting it worked.

I am using this plugin in my current project https://eonasdan.github.io/bootstrap-datetimepicker/

Anirudha Gupta
  • 9,073
  • 9
  • 54
  • 79
0

Here is Answer to the question

Add this in header

  <link href="~/Content/bootstrap-datetimepicker.css" rel="stylesheet" />
  <link href="~/Content/bootstrap-datetimepicker.min.css" rel="stylesheet" />

Now scripts (Placing at foot):

 @section Scripts {
 @Scripts.Render("~/bundles/jqueryval")
  <script type="text/javascript">
    $(function () {
        $('#datetimepicker1').datetimepicker();
    });
  </script>
<script type="text/javascript" src="~/Scripts/bootstrap-datetimepicker.js"></script>
Mesam Mujtaba
  • 114
  • 12