Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Datepicker default date Today

Please try add ")" at the end of code, you have missed it.

Andy Suciu
Posts: 0
Joined: Sun Jul 28, 2013 6:40 am

Datepicker default date Today

wow. great. thanks a lot!

Daniel6560000
Posts: 0
Joined: Wed Jan 08, 2014 5:52 pm

Datepicker default date Today

Good Day

Using this method, how can i set the default date to the first day of the year,
I thought of changing the
new Date()

by something like something like this:

var dateElement = Appery("todate");
var currDate = new Date();
...
dateElement.setProperty("defaultDateValue", $.datepicker.formatDate(dateElement.datepicker_dataPickerOptions.dateFormat, '01/01/'+currDate.getFullYear()));

What am I doing wrong please
Thanks

Daniel

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Datepicker default date Today

Hello! In $.datepicker.formatDate with a second parameter you have to pass not string, but object Date. If you have for datepicker the following Date Format mm/dd/yy
or
dd/mm/yy
Try this code prevar dateElement = Appery("todate");
var currDate = new Date();
dateElement.setProperty("defaultDateValue", '01/01/'+currDate.getFullYear());/pre

John6122514
Posts: 0
Joined: Wed Aug 07, 2013 7:10 pm

Datepicker default date Today

Hello.
I am using Maryna suggestion and it works great. Can you tell me how I would add days (+ 5) to the current date using this?

var dateElement = Appery("date");
dateElement.setProperty("defaultDateValue", $.datepicker.formatDate(dateElement.datepicker_dataPickerOptions.dateFormat, new Date()));

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Datepicker default date Today

Hi John,

Use this code please: prevar d = new Date(Appery("mobiletextinput").val());
d.setDate(d.getDate() + 5);
Appery("mobiletextinput").val(d.getYear + "-" + d.getMonth() + "-" + d.getDate());/preWhere 'mobiletextinput' is a name of date input component.

John6122514
Posts: 0
Joined: Wed Aug 07, 2013 7:10 pm

Datepicker default date Today

Sorry. That did not work. Just freezes

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Datepicker default date Today

Hi John,

Try this code please: prevar d = new Date(Appery("mobiletextinput").val());
d.setDate(d.getDate() + 5);

var dd = d.getDate();
var mm = d.getMonth()+1; //January is 0!

var yyyy = d.getFullYear();
if (dd < 10) {dd='0'+dd}
if (mm < 10) {mm='0'+mm}
mydate = yyyy+'-'+mm+'-'+dd;
Appery("mobiletextinput")&#46;val(mydate);
/preWhere 'mobiletextinput' is a name of date input component.

This code will increase current date component value by 5 days.

John6122514
Posts: 0
Joined: Wed Aug 07, 2013 7:10 pm

Datepicker default date Today

The script runs but it does not set the date.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Datepicker default date Today

Hi John - are there any errors in the console?

You can also try to debug the code - to see what values are passing.
:: http://docs.appery.io/documentation/d...

Return to “Issues”