I am trying to implement JQuery Datetimepicker into my MVC application. I have added all the reference into this but still throwing error
GET http://localhost:53987/Home/assets/img/demo/m2.jpg 404 (Not Found)
Uncaught TypeError: $ is not a function
_Layout.cshtml code
!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>@ViewBag.Title - Arion Pedigrees</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar-header">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown">Reports</a>
<ul class="dropdown-menu dropdown-menu-left animated-2x animated fadeIn">
<li>@Html.ActionLink("AA", "Index", "Home")</li>
<li>@Html.ActionLink("BB", "Index", "Home")</li>
</ul>
</li>
</nav>
<div class=" ">
@RenderBody()
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>
</html>
This the code:
@Html.TextBoxFor(m => m.StartDate, new { @class = "form-control"})
@Html.TextBoxFor(m => m.FinishDate, new { @class = "form-control" })
And then JavaScript code:
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script type="text/javascript">
$.noConflict();
$(document).ready(function () {
$("#StartDate").datepicker({
numberOfMonths: 1,
onSelect: function (selected) {
$("#FinishDate").datepicker("option", "minDate", selected)
}
});
$("#FinishDate").datepicker({
numberOfMonths: 1,
onSelect: function (selected) {
$("#StartDate").datepicker("option", "maxDate", selected)
}
});
});
</script>
Anyone please guide me. I do not understand where i am going wrong. The same code works for my another application. Any help is highly appreciated.
$after jQuery is included in the page ? Check your view source of the page to confirm that.$.noConflict();- If your then getting a $(...).datepicker is not a function is because your loading another copy ofjQuery.jsafter the one in your view (probably in your Layout)