display jquery yearly calendar - javascript

I want to display jquery yearly calendar as shown in image.
now I displayed only monthly calendar JSFiddle
$(function () {
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<p>Date:
<div id="datepicker"></div>
</p>

You can add
numberOfMonths: [3, 4] in you jquery
FIDDLE EXAMPLE
you can edit the [Row,Column] as per your need

Use this script:
$(function () {
$("#datepicker").datepicker({
changeMonth: true,
changeYear: true,
numberOfMonths: [3,4]
});
});
Thanks
Amit

Related

Dynamically set maximum date in jquery (javascript)

<div class="demo">
<p>Date: <input type="text" id="datepicker"></p>
</div><!-- End demo -->
$(function() {
$( "#datepicker" ).datepicker({
changeYear: true,
minDate: '-3M',
maxDate: '+28D',
});
});
I want to give admin power so that they can dynamically set the maximum date from the drop down. For e.g - if admin selects 3 from drop down it should automatically reflect in maxDate.
Here is your solution
I added new dropdown where admin select value it will automatically add in MaxDate
var newdate=$("#selected").val();
function getdate() {
console.log(newdate)
$("#datepicker").datepicker("destroy");
$( "#datepicker" ).datepicker({
changeYear: true,
minDate: '-3M',
maxDate: '+'+newdate+'D',
});
}
$( "#datepicker" ).datepicker("refresh");
getdate()
function change(){
newdate=$("#selected").val();
getdate()
}
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<div class="demo">
<p>Date: <input type="text" id="datepicker"></p>
<select id="selected" onchange="change()">
<option>3</option>
<option>4</option>
</select>
</div><!-- End demo -->

jQuery datepicker not working in paragraph

I have this small issue where I can't figure out why this datepicker doesn't work:
The HTML part is:
Test <input type="text" id="date1" name="date1"/>
<p>Startdatum:<input type="text" id="startTime"></p>
<p>Enddatum:<input type="text" id="endTime"/></p>
The JavaScript part is:
$('#startTime').datepicker({
dateFormat: "dd/mm/yy"
});
$('#endTime').datepicker({
dateFormat: "dd/mm/yy"
});
$('#date1').datepicker({
dateFormat: "m/d/yy"
});
Here's a JSFiddle: https://jsfiddle.net/h10t7ed6/
Can someone tell me why the datepicker doesn't appear?
You need JQuery UI support as well:
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
Also,
<script>
$(function() {
$('#startTime').datepicker({
dateFormat: "dd/mm/yy"
});
$('#endTime').datepicker({
dateFormat: "dd/mm/yy"
});
$('#date1').datepicker({
dateFormat: "m/d/yy"
});
});
</script>

jQuery date picker year 1927 format dd mm y issue

jQuery DatePicker for format dd mm y breaking
I type in 01 01 27 it breaks it doesn't shows the date selected in calendar
Is it a jQuery bug ?
It accepts all values above year 1927
HTML
<p>Date: <input type="text" id="datepicker"></p>
JS
$( "#datepicker" ).datepicker({
dateFormat: "dd mm y",
changeMonth: true,
changeYear: true,
minDate: "-100Y",
maxDate: "-18Y"
});
$(function () {
$( "#datepicker" ).datepicker({
dateFormat: "dd mm y",
changeMonth: true,
changeYear: true,
minDate: "-100Y",
maxDate: "-18Y"
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<p>Date: <input type="text" id="datepicker"></p>
looks like yearRange is something you can use:
$(function() {
$("#datepicker").datepicker({
dateFormat: "dd mm y",
changeMonth: true,
changeYear: true,
yearRange: "c-100:c-18"
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<p>Date: <input type="text" id="datepicker"></p>
I have figured out the answer
adding
shortYearCutoff: "1", solves my problem
For more details check here

Jquery datepicker, select year

I would like to have more than 11 dates to choose from, instead I'd like to have all possible years in one single dropdown
This is my code:
$( function() {
$( "#data" ).datepicker({
changeMonth: true,
changeYear: true,
minDate: "-100Y",
maxDate: "-18Y"
});
} );
I would like to have full selection from 1917 to 1999
Try this :
$(function() {
$("#data").datepicker({
changeMonth: true,
changeYear: true,
yearRange: "-100:-18"
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<input type="text" id="data" />

How to display month name in multi-datepicker plugin?

I am trying to displaying multiple date picker range format like(Mar 2, 2015 - Mar 12, 2016) used one plugin http://multidatespickr.sourceforge.net/ and I tried following code
$(function() {
$(".datepicker").multiDatesPicker({
minDate: 0,
showButtonPanel: true,
changeMonth: true,
changeYear: true,
onSelect: function(dateText, inst) {
inst.settings.defaultDate = dateText;
}
});
});
but it is not working, someone help me?
You may not need onSelect handler. It is easily possible to do with following setting:
dateFormat: "M d, yy",
separator:' - '
$(function() {
$("#dp").multiDatesPicker({
dateFormat: 'M d, yy',separator:' - '
});
});
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script src="http://multidatespickr.sourceforge.net/jquery-ui.multidatespicker.js"></script>
<link rel="stylesheet" href="http://multidatespickr.sourceforge.net/css/pepper-ginder-custom.css" />
<input id="dp" type="text" />

Categories

Resources