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());
            });
         });
1

4 Answers 4

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']);

Sign up to request clarification or add additional context in comments.

Comments

0

Try using below code:

var changedDate = $("#<%=txtChqDate.ClientID %>").datepicker({ dateFormat: 'dd-mm-yy' }).val();

Comments

0

It looks like you are missing the dateFormat after option

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

Comments

0

try this

 $("#<%=txtChqDate.ClientID %>").datepicker("option", "dateFormat", "dd-M-yy");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.