Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default value for jquery date picker

I have some questions regarding jQuery UI date picker.

1 - Is there an option to have a default value? What I am trying to do is pre-filled my input text type with today's date.

2 - If I put the type = "Date" instead of type = "Text" and then use jquery time picker on it, I get this error when I select the date.

 The specified value '02/18/2015' does not conform to the required format, 'yyyy-MM-dd.'

How do I solve this?

like image 665
mohsinali1317 Avatar asked Feb 19 '15 10:02

mohsinali1317


1 Answers

To create the date picker and set the date. You can assign today's date by 'new Date().' You can set input type=text or type=date.

$('.datepicker').datepicker({ 
     dateFormat: 'dd-mm-yy'
     }).datepicker("setDate", new Date());
like image 189
Sadikhasan Avatar answered Oct 03 '22 09:10

Sadikhasan