0

The following results in: Uncaught TypeError: Cannot read property 'formatDate' of undefined I have all three files in the same directory (jquery, jquery-ui and this html file):

<html>
<head>
<link rel="stylesheet" href="jquery-ui.min.css">
<script src="jquery-1.11.1.min.js"</script>
<script src="jquery-ui.min.js"</script>
<script>
$(document).ready(function(){
  var $t = $.datepicker.formatDate("M dd", new Date("2014-12-01"));
  console.log($t);
});
</script>
</head>
<body>
</body>
</html>

What am I doing wrong?

4 Answers 4

2

If this is your actual HTML, you should change

<script src="jquery-1.11.1.min.js"</script>
<script src="jquery-ui.min.js"</script>

into

<script src="jquery-1.11.1.min.js"></script>
<script src="jquery-ui.min.js"></script>
Sign up to request clarification or add additional context in comments.

2 Comments

what the difference between these notes?
@AlexFilatov the opening script tags are closed in the second version
1

You aren't loading the jquery-ui properly. You need a closing bracket.

Comments

1

I sloved the same error by using the FULL datepicker js file

<script src="/js/jquery.datetimepicker.full.js"></script>

available in Git Datetimepicker/build/

Comments

0

HTML:

<input type="text" id="your_input" name="your_input" />

JS:

  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
  <script>
  $(function() {
    $( "#your_input" ).datepicker();
  });
  </script>

Optional Fast load datapicker:

      <script src="//code.jquery.com/jquery-1.10.2.js"></script>
      <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
      <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
      <script>
      $(function() {
        $('body').on('focus',"#your_input", function(){
              $(this).datepicker({ dateFormat: 'dd-mm-yy' });
        });
      });
      </script>

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.