Another JQuery datepicker question
-
Hi all, I copied the html shown below from a tutorial on how to use the JQuery datepicker. If I run it in Visual Studio ( it's part of an MVC project) it works perfectly. I want to add the functionality of this to my personal project which is a net core Web app I've tried adding the link and script references to _layout.cshtml and set the id of my date properties to "datepicker" but I don't see the datepicker popup. Anyone know what I'm doing wrong or missing ?
@{
ViewBag.Title = "Index";
}
@model JQueryDatePicker.Models.Customer
@using (Html.BeginForm("index", "home"))
{@Html.LabelFor(c => c.JoinDate) @Html.TextBoxFor(c => c.JoinDate, new { id = "datepicker" }) Submit
}
$("#datepicker").datepicker({ changeMonth: true, changeYear: true, numberOfMonths: 2, dateFormat: 'dd-mm-yy' });
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
-
Hi all, I copied the html shown below from a tutorial on how to use the JQuery datepicker. If I run it in Visual Studio ( it's part of an MVC project) it works perfectly. I want to add the functionality of this to my personal project which is a net core Web app I've tried adding the link and script references to _layout.cshtml and set the id of my date properties to "datepicker" but I don't see the datepicker popup. Anyone know what I'm doing wrong or missing ?
@{
ViewBag.Title = "Index";
}
@model JQueryDatePicker.Models.Customer
@using (Html.BeginForm("index", "home"))
{@Html.LabelFor(c => c.JoinDate) @Html.TextBoxFor(c => c.JoinDate, new { id = "datepicker" }) Submit
}
$("#datepicker").datepicker({ changeMonth: true, changeYear: true, numberOfMonths: 2, dateFormat: 'dd-mm-yy' });
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
I added type="datetime" to the anonymous type and tweaked the script to the below and it worked. The added bonus is it works for all datetime properties
$(document).ready(function () {
$('input[type=datetime]').datepicker({
numberOfMonths: [1, 1],
dateFormat: "dd-M-yy",
changeMonth: true,
changeYear: true
});
});@Html.TextBoxFor(m => m.DateUsed,new {type="datetime"})
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
-
Hi all, I copied the html shown below from a tutorial on how to use the JQuery datepicker. If I run it in Visual Studio ( it's part of an MVC project) it works perfectly. I want to add the functionality of this to my personal project which is a net core Web app I've tried adding the link and script references to _layout.cshtml and set the id of my date properties to "datepicker" but I don't see the datepicker popup. Anyone know what I'm doing wrong or missing ?
@{
ViewBag.Title = "Index";
}
@model JQueryDatePicker.Models.Customer
@using (Html.BeginForm("index", "home"))
{@Html.LabelFor(c => c.JoinDate) @Html.TextBoxFor(c => c.JoinDate, new { id = "datepicker" }) Submit
}
$("#datepicker").datepicker({ changeMonth: true, changeYear: true, numberOfMonths: 2, dateFormat: 'dd-mm-yy' });
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
pkfox wrote:
<script src="//code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
That's a really old version of jQuery, which no longer receives patches. The current version is 3.6.0; you only need to stick to the v1 branch if you need to support Internet Explorer 6-8, Opera 12, or Safari 5. Browser Support | jQuery[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
pkfox wrote:
<script src="//code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>
That's a really old version of jQuery, which no longer receives patches. The current version is 3.6.0; you only need to stick to the v1 branch if you need to support Internet Explorer 6-8, Opera 12, or Safari 5. Browser Support | jQuery[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Thanks Richard - as I said I copied it from a tutorial for use in a personal project so no big deal - I'll update the links though - do I need to update the css also ?
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
The jQuery UI reference looks OK - the latest version is 1.12.1, so you're not too far behind. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
The jQuery UI reference looks OK - the latest version is 1.12.1, so you're not too far behind. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer