JSFiddle - React, Tailwind, and code Playground
by Semih Muyaoğlu
HTML
<label for="from">From</label>
<input type="text" id="from" name="from">
<label for="to">to</label>
<input type="text" id="to" name="to">
CSS
/* DatePicker Container */
.ui-datepicker {
width: 264px;
height: auto;
margin: 5px auto 0;
font: 9pt Arial, sans-serif;
}
.ui-datepicker a {
text-decoration: none;
}
/* DatePicker Table */
.ui-datepicker table {
width: 100%;
}
.ui-datepicker-header {
background: #fff;
color: #e0e0e0;
font-weight: bold;
line-height: 30px;
border-width: 1px 0 0 0;
border-style: solid;
border-color: #111;
}
.ui-datepicker-title {
text-align: center;
}
.ui-datepicker-prev, .ui-datepicker-next {
display: inline-block;
width: 30px;
height: 30px;
text-align: center;
cursor: pointer;
background-image: url('../img/arrow.png');
background-repeat: no-repeat;
line-height: 600%;
overflow: hidden;
}
.ui-datepicker-prev {
float: left;
background-position: center -30px;
}
.ui-datepicker-next {
float: right;
background-position: center 0px;
}
.ui-datepicker thead {
border-bottom: 1px solid #bbb;
}
.ui-datepicker th {
text-transform: uppercase;
font-size: 6pt;
padding: 5px 0;
color: #666666;
text-shadow: 1px 0px 0px #fff;
filter: dropshadow(color=#fff, offx=1, offy=0);
}
.ui-datepicker tbody td {
padding: 0;
border-right: 1px solid #bbb;
}
.ui-datepicker tbody td:last-child {
border-right: 0px;
}
.ui-datepicker tbody tr {
border-bottom: 1px solid #bbb;
}
.ui-datepicker tbody tr:last-child {
border-bottom: 0px;
}
.ui-datepicker td span, .ui-datepicker td a {
display: inline-block;
font-weight: bold;
text-align: center;
width: 30px;
height: 30px;
line-height: 30px;
color: #666666;
}
.ui-datepicker-calendar .ui-state-default {
background: #ededed;
}
.ui-datepicker-calendar .ui-state-hover {
background: #fff;
}
.ui-datepicker-calendar .ui-state-active {
background: pink;
color: #e0e0e0;
border: 0 solid #55838f;
position: relative;
margin: -1px;
}
.ui-datepicker-unselectable .ui-state-default {
background: #f4f4f4;
color: #b4b3b3;
}
.ui-datepicker-calendar td:first-child .ui-state-active...
JavaScript
$( function() {
// özellikler
var dateFormat = "dd.mm.yy",
from = $( "#from" ) .datepicker(
{
rangeSelect: true,
dayNamesMin: ['Pz', 'Pts', 'Sal', 'Çar', 'Per', 'Cum', 'Cts'],
onSelect: function( selectedDate )
{
$( "#to" ).datepicker("option", "minDate", selectedDate );
setTimeout(function(){ $( "#to" ).datepicker('show'); }, 16);
}
}),
to = $( "#to" ).datepicker(
{
rangeSelect: true
}).on( "change", function()
{
from.datepicker( "option", "maxDate", getDate( this ) );
});
// tarihleri çağırttır
function getDate( element ) {
var date;
try { date = $.datepicker.parseDate( dateFormat, element.value ); }
catch( error ) { date = null; }
return date;
};
});