JQuery Datepicker Rails 3 Date Format Error

I am trying to use the jQuery UI datpicker for a form to create an event.

The rendering form itself is great, and if I use the usual rails date_field, the information is saved without any problems. However, when I try to use datepicker, it claims that the form cannot be empty, even if I selected the date. I understand that this is due to the difference in the date format used by rails and datepicker, so I tried the following code:

$(function(){
    $("#dateField").datepicker({
        dateFormat: "yyyy-mm-dd"
    });
}); 

But that didn't seem to work. The date is still displayed in the default datepickers format and passes this format as a parameter, resulting in an error. Any pointers would be appreciated!

+5
source share
3 answers

.

:

$(function (){
$('#dateField').datepicker({ dateFormat: 'D, dd M yy' });
});

Rails.

, , ( ), string, date.

+4

, ? ?

jQuery(document).ready(function($) {
    $("#dateField").datepicker({
        dateFormat: "yyyy-mm-dd"
    });

})

?

+2

The answer is deprecated, with Postgres and the Datetime field that I used
 {format: "dd/mm/yyyy"} and it really worked.

0
source

All Articles