pheromix
pheromix

Reputation: 19317

Which libraries are used in order to show datepickers?

I want to show a datepicker popup when an input element gets focus :

    $(document).ready(function(){
        $(".datepicker").on('click',function(){
            $(this).datepicker({
                buttonImageOnly: true,
                changeMonth: true,
                changeYear: true,
                showWeek: true,
                firstDay: 1
            });
            $(this).datepicker('show');
        });
    });

Which js files are required in order for this code to work ?

Upvotes: 0

Views: 739

Answers (3)

Satpal
Satpal

Reputation: 133403

You need jQuery UI library and you can simply use:

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<script>
$(document).ready(function() {
    $(".datepicker").datepicker({
        buttonImageOnly: true,
        changeMonth: true,
        changeYear: true,
        showWeek: true,
        firstDay: 1
    });
});
</script>

Upvotes: 2

laurent.lefevre
laurent.lefevre

Reputation: 60

Datepicker is part of jquery UI, here is an example :

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>

Upvotes: 1

Abhishek
Abhishek

Reputation: 196

<script src="Scripts/jquery-ui-1.10.4.js"></script>
<link href="Content/jquery-ui-1.10.4.css" rel="stylesheet" />

Upvotes: 1

Related Questions