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?
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?
Share Improve this question asked Nov 5, 2014 at 22:13 kmansoorkmansoor 4,34510 gold badges55 silver badges95 bronze badges4 Answers
Reset to default 2If 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>
You aren't loading the jquery-ui properly. You need a closing bracket.
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/
HTML:
<input type="text" id="your_input" name="your_input" />
JS:
<script src="//code.jquery./jquery-1.10.2.js"></script>
<script src="//code.jquery./ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery./ui/1.11.2/themes/smoothness/jquery-ui.css">
<script>
$(function() {
$( "#your_input" ).datepicker();
});
</script>
Optional Fast load datapicker:
<script src="//code.jquery./jquery-1.10.2.js"></script>
<script src="//code.jquery./ui/1.11.2/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery./ui/1.11.2/themes/smoothness/jquery-ui.css">
<script>
$(function() {
$('body').on('focus',"#your_input", function(){
$(this).datepicker({ dateFormat: 'dd-mm-yy' });
});
});
</script>