How do i set "Default Date", "Min Date" and "Max date" values for a date picker using java script?
How do i set "Default Date", "Min Date" and "Max date" values for a date picker using java script?
Hi Girish,
Please use following code go define custom parameters for your datepicker component:
pre
var options = {
dateFormat: "mm/dd/yy",
firstDay: 0,
Code: Select all
maxDate: new Date("10/30/2014"),
minDate: new Date("10/08/2014"),
dayNamesMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
showOtherMonths: true,
defaultDate: new Date("11/08/2014")
};
new Apperyio.ApperyMobileDatePickerComponent("test_mobiledatepicker_239", options)
/pre
Regards.
Thanks. Guess this is for creating a date picker component dynamially via JavaScript. But I just need to 1) read and 2) modify the parameters of an existing date picker component in my page. Can you pls suggest for point 1 and 2?
Hello Girish,
You can change default, min and max dates this way:
Apperyio("mobiledatepicker_13").datepicker_dataPickerOptions.defaultDate = new Date()
Apperyio("mobiledatepicker_13").datepicker_dataPickerOptions.minDate = new Date()
Apperyio("mobiledatepicker_13").datepicker_dataPickerOptions.maxDate = new Date()
Apperyio("mobiledatepicker_13").initializeDataPicker()
Thanks, that worked. Now i need to get the date value set. When i tried this, it doesnt work
Apperyio("mobiledatepicker_13").val()
Hi Girish,
Here is code to get value:
pre
var date = Apperyio("mobiledatepicker_239").datepicker_dataPickerOptions.defaultDate;
/pre
Regards.
what if i want the new date to be the current date, can i read it somehow from the phone? if yes, how can i do that?
Hello,
Please read it with JS:
var value = (new Date()).toISOString();