jQuery : Datepickers

In jQuery, datepickers() allow the user to customize the date format and language. It also has the ability to easily restrict the selectable date ranges which users may find it very convenient. Datepicker is an interactive calendar on a small overlay and on the input, it's either you click or use the tab key when choosing a date. The jQuery contains methods that generates a date picker that changes the looks of HTML elements on a web page. Syntax: You can use datepicker() method in two ways:
  • $(selector).datepicker (options)
  • $(selector).datepicker (“action”, [params])
Description: selector – can be used with an class, id, and name of HTML elements. options – It specifies the looks and behaviors of the date picker elements.
$(selector).datepicker (options) examples:
  • Defaults
    1. <!doctype html>
    2. <html lang="en">
    3. <meta charset="utf-8">
    4. <title>jQuery UI Datepicker - Default</title>
    5. <link rel="stylesheet" href="jquery-ui.css">
    6. <script src="jquery-2.2.4.min.js"></script>
    7. <script src="jquery-ui.js"></script>
    8. $(function() {
    9. $("#datepickers" ).datepicker();
    10. });
    11. </script>
    12. <style type="text/css">
    13. input {
    14. height: 21px;
    15. font-size: 15px;
    16. }
    17. p {
    18. font-size: 15px;
    19. text-align: left;
    20. }
    21. h1{
    22. text-align: left;
    23. }
    24. </style>
    25. </head>
    26. <h1>Date Picker Default Execution</h1>
    27. <p>Date: <input type="text" class="input" id="datepickers"></p>
    28.  
    29. </body>
    30. </html>
  • Alternate Date
    1. <!doctype html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="utf-8">
    5. <title>jQuery UI Datepicker Alternate</title>
    6. <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet">
    7. <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    8. <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    9. <!-- Javascript -->
    10. $(function() {
    11. $( "#datepickers1" ).datepicker({
    12. dateFormat:"mm / dd / yy",
    13. altField: "#datepickers2",
    14. altFormat: "DD, d MM, yy"
    15. });
    16. });
    17. </script>
    18. </head>
    19. <body>
    20. <!-- HTML -->
    21. <p>Enter Date: <input type="text" id="datepickers1"></p>
    22. <p>Alternate Date: <input type="text" id="datepickers2"></p>
    23. </body>
    24. </html>
  • buttonImageOnly, buttonImage, and showOn
    1. <!doctype html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="utf-8">
    5. <title>jQuery UI Datepicker buttonImage, buttonImageOnly and showOn</title>
    6. <link href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet">
    7. <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    8. <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    9. <!-- Javascript -->
    10. $(function() {
    11. $( "#datepickers4" ).datepicker({
    12. showOn:"button",
    13. buttonImage: "/jqueryui/images/calendar-icon.png",
    14. buttonImageOnly: true
    15. });
    16. });
    17. </script>
    18. </head>
    19. <body>
    20. <!-- HTML -->
    21. <p>Enter Date: <input type="text" id="datepickers4"></p>
    22. </body>
    23. </html>
  • defaultDate, dayNamesMin, and duration
    1. <!doctype html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="utf-8">
    5. <title>jQuery UI Datepicker </title>
    6. <link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
    7. <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    8. <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    9. <!-- Javascript -->
    10. $(function() {
    11. $( "#datepickers5" ).datepicker({
    12. defaultDate:+9,
    13. dayNamesMin: [ "Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat" ],
    14. duration: "slow"
    15. });
    16. });
    17. </script>
    18. </head>
    19. <body>
    20. <!-- HTML -->
    21. <p>Enter Date: <input type="text" id="datepickers5"></p>
    22. </body>
    23. </html>
  • showWeek and showAnim
    1. <!doctype html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="utf-8">
    5. <title>jQuery UI Datepicker showWeek and showAnim functionality</title>
    6. <link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
    7. <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    8. <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    9. <!-- Javascript -->
    10. $(function() {
    11. $( "#datepickers6" ).datepicker({
    12. showWeek:true,
    13. showAnim: "slide"
    14. });
    15. });
    16. </script>
    17. </head>
    18. <body>
    19. <!-- HTML -->
    20. <p>Enter Date: <input type="text" id="datepickers6"></p>
    21. </body>
    22. </html>
    23.  
$(selector).datepicker (“action”, [params]) Example:
  • setDate()action
    1. <!doctype html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="utf-8">
    5. <title>jQuery UI Datepicker setDate function</title>
    6. <link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
    7. <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    8. <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    9. <!-- Javascript -->
    10. $(function() {
    11. $( "#datepickers7" ).datepicker();
    12. $( "#datepickers7" ).datepicker("setDate", "6w+1");
    13. });
    14. </script>
    15. </head>
    16. <body>
    17. <!-- HTML -->
    18. <p>Enter Date: <input type="text" id="datepickers7"></p>
    19. </body>
    20. </html>
For all students who need a programmer for your thesis system or anyone who needs a source code in any programming languages. You can contact me @ : Email – [email protected] Mobile No. – 09305235027 – TNT

Add new comment