0

I want to change the date format to dd-MM-yyyy currently the date format of my jQuery date pickeris MM-dd-yyyy below is my code in asp webforms but its not working

<link href="../Contents/css/jquery-ui.css" rel="stylesheet" />
    <script src="../Contents/js/jquery-1.8.2.js"></script>
    <script src="../Contents/js/jquery-ui.js"></script>
     <script>
        $(function () {
            $("#<%=txtChqDate.ClientID %>").datepicker();
            $("#<%=txtChqDate.ClientID %>").datepicker("option", "showAnim", "drop");
            <%--$("#<%=txtChqDate.ClientID %>").datepicker({ dateFormat: 'dd/mm/yy' });   --%>
            $("#format").change(function () {
                $("#<%=txtChqDate.ClientID %>").datepicker("option", "dd-mm-yyyy", $(this).val());
            });
         });
Sumit Bhattarai
  • 308
  • 2
  • 19

4 Answers4

1

You can add the following code in the master page to set it as a default for all datepicker instances, UK has a date format of MM/DD/YYYY

$.datepicker.setDefaults($.datepicker.regional['en-GB']);

Haitham Shaddad
  • 4,336
  • 2
  • 14
  • 19
0

Try using below code:

var changedDate = $("#<%=txtChqDate.ClientID %>").datepicker({ dateFormat: 'dd-mm-yy' }).val();
Geeky Ninja
  • 6,002
  • 8
  • 41
  • 54
0

It looks like you are missing the dateFormat after option

$("#`<%=txtChqDate.ClientID %>").datepicker("option", "dateFormat","dd-mm-yyyy", $(this).val());

Damian
  • 74
  • 5
0

try this

 $("#<%=txtChqDate.ClientID %>").datepicker("option", "dateFormat", "dd-M-yy");
Pawan Lakhara
  • 1,146
  • 4
  • 16
  • 28