how to change start year from date picker in materillize - css

I want to set start year from using materialize css and want to year start from 1990
HTML
<input type="text" class="datepicker">
JS
$(document).ready(function(){
$('.datepicker').datepicker();
});

With Materialize version one
$(document).ready(function(){
$('.datepicker').datepicker({
yearRange: 59
});
Or alternatively, provide an array of the years you want... that can be easily done in Javascript
$(document).ready(function(){
$('.datepicker').datepicker({
yearRange: [1970,2019]
});

set range to datepicker
$(function(){
$(".datepicker").datepicker({
changeMonth: true,
changeYear: true,
yearRange: '1990:'+(new Date).getFullYear()
});
});

You can modify you javascript as given bellow to adjust year according you. I hope this will work for you.
$('.datepicker').pickadate({
selectMonths: true, // Creates a dropdown to control month
selectYears: 40 // Creates a dropdown of 15 years to control year
});

Related

Bootstrap Datepicker with Asp.Net Textbox

Maybe it will be a silly question but I couldn't handle my problem. I checked all the questions and answers on here but I didn't find any clue. Anyway, I want to use the bootstrap datepicker with asp.net textbox. When I use it with input without the runat="server" tag, I see that the datepicker shows up, but when I try to use it with textbox with the runat="server" tag, the datepicker is not showing. Any idea on how to solve this issue?
<asp:TextBox ID="DateTextbox" runat="server" CssClass="m-wrap span12 date form_datetime"></asp:TextBox>
<script type="text/javascript">
$(document).ready(function () {
var dp = $("#<%=DateTextbox.ClientID%>");
dp.datepicker({
changeMonth: true,
changeYear: true,
format: "dd.mm.yyyy",
language: "tr"
});
});
</script>
Thanks for your answers.
thanks for your answers. i did a lil change on my code its working now. i am posting for further use.
<script type="text/javascript">
$(document).ready(function () {
var dp = $('#<%=DateTextbox.ClientID%>');
dp.datepicker({
changeMonth: true,
changeYear: true,
format: "dd.mm.yyyy",
language: "tr"
}).on('changeDate', function (ev) {
$(this).blur();
$(this).datepicker('hide');
});
});
</script>
but i dont understand whats make the diffrence between (") and (') ?
Try this
<asp:TextBox ID="DateTextbox" ClientIDMode="Static" runat="server" CssClass="m-wrap span12 date form_datetime"></asp:TextBox>
<script type="text/javascript">
$(document).ready(function () {
var dp = $("#DateTextbox");
dp.datepicker({
changeMonth: true,
changeYear: true,
format: "dd.mm.yyyy",
language: "tr"
});
});
</script>
If you're not against simply using a class, you can leverage the date class on your input, like so:
<script>
$(function () {
$('input.date').datepicker({
changeMonth: true,
changeYear: true,
format: "dd.mm.yyyy",
language: "tr"
});
});
</script>
The disadvantage is that you're targeting more elements (potentially), but unless you have a crazy number of inputs in your form, it shouldn't make a noticeable difference.

jquery datepicker max date min date control using two date picker

what I have : I have two datepicker calender control in jquery where 1st can only choose date current date and previous date but not future date for that I have written the code which works fine
<script type="text/javascript">
$(function () {
$("#from").datepicker({ maxDate: 0 });
});
</script>
Now I have to use another textbox with datepicker which can only select dates between the date selected in 1st textbox and current date.
Now having these conditions what code should I write for my second datepicker.
my project is in Asp .net using c#. Any help would be appreciated
Please try the below:
<script type = "text/javascript">
$(function () {
$("#from").datepicker({
onSelect: function (date) {
$("#to").datepicker("option","minDate", date);
$("#to").datepicker("option","maxDate", new Date());
},
maxDate: 0
});
});
</script>

Yii - FullCalendar - How set TimeZone?

I'm using FullCalendar:
http://arshaw.com/fullcalendar/
Is it possible to set the time zone? I'd like to allow my users to select the timezone they'd like to view the calendar. Right now, the event times ONLY change if I change the system time on my laptop computer. I'm using version 1.5.3 and saw this in the documentation:
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
events: {
url: 'http://www.google.com/your_feed_url/',
className: 'gcal-event', // an option!
currentTimezone: 'America/Chicago' // an option!
}
});
});
</script>
I've tried setting currentTimezone and the times don't change. I've also searched through the included javascript files and can't any references of 'currentTimezone'. How is this possible in versions 1.5+?
Try setting ignoreTimezone to false.
<script type='text/javascript'>
$(document).ready(function() {
$('#calendar').fullCalendar({
events: {
url: 'http://www.google.com/your_feed_url/',
className: 'gcal-event', // an option!
currentTimezone: 'America/Chicago' // an option!
},
ignoreTimezone: false
});
});
</script>
Let me know if this helps.

jquery datepicker onselect not firing

I have 2 input boxes for inputing start date and end date.I need to verify that the start date is earlier than the end date.I have the following code to verify that but the code doesn't seem to be firing when I attach to the onselect event of the datepicker control.Can someone please tell what I'm doing wrong?
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$(".date").datepicker({
onSelect:function(dateText,inst){
var startDate=new Date($("#_createDateFromInput").val());
var endDate=new Date($("#_createDateToInput").val());
if(startDate!=""&&endDate!="")
{
if(startDate>endDate)
{
alert("End date cannot be earlier than start date");
}
}
}
});});
</script>
thanks!!
The markup for the above is(this is in asp.net):
<label>Date From</label>
<input class="date" runat="server" id="_createDateFromInput" />
<label id="to">To</label>
<input class="date" runat="server" id="_createDateToInput" />
El Ronnoco had I believe has latched onto something...I notice when I remove the runat="server" tag I am able to fire the even...however now I am faced with another
issue to retrieve the value during post back(i.e when user finally submits)..any one have an idea?
A simpler way to achieve this is to prevent that the user can select an earlier date for the endDate.
This can be simply done by using the minDate option of Datepicker plugin
$("#startDate").datepicker({
onSelect:function(dateText,inst){
$( "#endDate" ).datepicker( "option", "minDate", new Date(dateText) );
}
});
I use this code, from the jQuery UI example page: http://jqueryui.com/demos/datepicker/#event-search
Basically it takes 2 inputs, makes them datepickers then onselect limits both the mindate and max date. It's a very clever piece of code.
$(function() {
var dates = $( "#from, #to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 3,
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" );
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});
thanks guys for all your input.I used a lot of what you had written down.I was able to make that work for some reason having the attribute runat="server" causes all kinds of problems for jquery.I had to remove the tag and access it using the request object that is inherent in the page.For those interested in the syntax:
request.form["startDate"].tostring();
where startdate is the attribute name value for that field.

How to select input date as default in JQuery datepicker?

I have an ASP.NET application which uses JQuery datepicker for picking dates in some text boxes. For some date textboxes, I populate the date textbox from my database. When this textbox is clicked my JQuery datepicker appears, and it shows the current month with Today highlighted. This is fine for empty textboxes, however sometimes the text box is populated from the database.
When the textbox is not empty I want the datepicker to show the textbox month and have the selected date to be the textbox date.
Is this possible?
Here's my current javascript code in my asp.net script header:
<script type="text/javascript">
$(function () {
$('#myTextBox').datepicker({
dateFormat: 'dd-M-yy',
numberOfMonths: 2,
autoSize: true,
changeMonth: true,
changeYear: true,
showButtonPanel: true,
maxDate: 0
});
});
</script>
Thanks,
Mark.
You need to make sure that the format of your datepicker matches the format output by your serverside code. If they're exactly the same then it'll work. It won't try to parse the date if it's in a different format though.
You need to use defaultDate. Example:
<script type="text/javascript">
$(function () {
$('#myTextBox').datepicker({
dateFormat: 'dd-M-yy',
numberOfMonths: 2,
autoSize: true,
changeMonth: true,
changeYear: true,
showButtonPanel: true,
maxDate: 0,
defaultDate: new Date()
});
});
</script>
This will initialize the default date to today's date. You need to add server side code that will initialize defaultDate to whatever you want.

Resources