Hi Team
I want to create datepicker, somehow when i debug i often get this annoying error as "
Index:187 Uncaught TypeError: $(...).datepicker is not a function
at HTMLDocument.<anonymous> (Index:187)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at Function.ready (jquery.min.js:2)
at HTMLDocument.K (jquery.min.js:2)
". Have a look at my libraries and yet Datepicker is already installed on Nuget command.
What I have tried:
// Libraries imported on View.cshtml
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css">
//
<div class="form-group">
<label asp-for="Date_Created" class="control-label"></label>
<input asp-for="Date_Created" id="datepicker" type="text" class="form-control" value="@DateTime.Now.ToString("yyyy-MM-ddThh:mm")" />
<span asp-validation-for="Date_Created" class="text-danger"></span>
</div>
<script>
$(document).ready(function () {
$(".datepicker").datepicker({
dateFormat: "dd-mm-yy",
changemonth: true,
changeyear: true
});
});
</script>
//___Layout.cshtml
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<!---Adding a picture for customization-->
<div class="container body-content">
@RenderBody()
<hr />
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)