jquery datepicker not formatting the date

All I want is for the date to be in dd/mm/yyyy format when it is inserted into the input box but it comes through as the default mm/dd/yyyy. When I insert the date into the input with $("#midmonthstart_"+uid).val(formated); I have read on the API docs that will format it, but I have got something wrong here.

function selectmiddate(uid){
$("#midmonthstart_"+uid).datepicker({
    format:'d/m/Y',
    date: $("#midmonthstart_"+uid).val(),
    current: $("#midmonthstart_"+uid).val(),
    starts: 1,
    position: 'r',
    onBeforeShow: function(){
        $("#midmonthstart_"+uid).DatePickerSetDate($("#midmonthstart_"+uid).val(), true);
    },
    onChange: function(formated, dates){
        $("#midmonthstart_"+uid).val(formated);
        $("#midmonthstart_"+uid).DatePickerHide();
    }
});
}

Answers


You should write :

function selectmiddate(uid){
$("#midmonthstart_"+uid).datepicker({
    dateFormat:'dd-mm-yy',
    date: $("#midmonthstart_"+uid).val(),
    current: $("#midmonthstart_"+uid).val(),
    starts: 1,
    position: 'r',
    onBeforeShow: function(){
        $("#midmonthstart_"+uid).DatePickerSetDate($("#midmonthstart_"+uid).val(),     true);
    },
    onChange: function(formated, dates){
        $("#midmonthstart_"+uid).val(formated);
        $("#midmonthstart_"+uid).DatePickerHide();
    }
  });
}

See the documentation:

http://api.jqueryui.com/datepicker/#option-dateFormat


Need Your Help

How to disable “note to buyer” in PayPal express checkout?

php paypal

I've got a problem integrating PayPal Express Checkout. I want to disable the possibility to add a note to the buyer during the checkout process.

SQL Server Variable Truncate

sql sql-server sql-server-2008

I know you could Truncate a Table or Table variable but is there a way to also truncate a variable ?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.