Datepicker is a date input method through a dialog that is specially designed to input the date. By using the datepicker, the user does not need to input date manually.
Many ways you can create a datepicker function on the input element. one of them by using jQuery UI. jQuery UI has provided a special function to display datepicker.For more details, let's look at the following steps.
Open your Text editor and create new file.
Save as date.html. recomended to save and run it on Webserver such as XAMPP, Apache etc. Because this function sometime can't run except in webserver.
Add the HTML element as usual.
<html>
<head>
<title>DatePicker</title>
</head>
<body>
</body>
</html>
Date: <input type="text" id="date">
Becouse we don't want to install or host the jQuery and jQuery UI file, we should add The CDN as replacement.
<head> element.<script src="http://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script> tag. You can put it in element or in <body> or in <head> element.<script></script>
$(function() for starting jQuery UI other function$(function(){
});
datepicker() function$("#date").datepicker();
show, slideDown, fadeIn, blind, bounce , clip, drop, fold, and slide. To add the animations on datepicker, select the input on more time and add the datepicker() function. then add the following parameter to datepicker().$("#date").datepicker( "option", "showAnim", "animationname");
So, the script become like this.
$("#date").datepicker();
$("#date").datepicker( "option", "showAnim", "slideDown");
Save the file and try to run. See the animation effect on your datepicker.
Change the animations as you want to make you more unserstand about this
showOtherMonths: true and selectOtherMonths: true to datepicker() parameter mehtod.$("#date").datepicker({
showOtherMonths: true,
selectOtherMonths: true
});
changeMonth: true, changeYear: true to datepicker parameter function.$("#date").datepicker({
changeMonth: true,
changeYear: true
});
showWeek: true, firstDay: 1 to datepicker parameter.$("#date").datepicker({
showWeek: true,
firstDay: 1
});
<html>
<head>
<title>DatePicker</title>
<script src="http://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
</head>
<body>
<center>
<h3>DATEPICKER</h3>
Date: <input type="text" id="date">
<h3>DATEPICKER ANIMATION</h3>
Date: <input type="text" id="animation">
<h3>DATEPICKER Show other Mont Date</h3>
Date: <input type="text" id="othermonth">
<h3>DATEPICKER Show month and years select</h3>
Date: <input type="text" id="monthandyear">
<h3>DATEPICKER Show week number</h3>
Date: <input type="text" id="showweek">
</center>
<script>
$(function(){
$("#date").datepicker();
$("#animation").datepicker();
$("#animation").datepicker( "option", "showAnim", "slideDown");
$("#othermonth").datepicker({
showOtherMonths: true,
selectOtherMonths: true
});
$("#monthandyear").datepicker({
changeMonth: true,
changeYear: true
});
$("#showweek").datepicker({
showWeek: true,
firstDay: 1
});
});
</script>
</body>
</html>
This is first Tutorial Contribution about jQuery UI