ivana_andreevska

Datepicker so MinDate i MaxDate

Jan 7th, 2022
1,490
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.92 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Title</title>
  6.     <link rel="stylesheet" href="jquery_ui.css">
  7.     <script src="jquery.js"></script>
  8.     <script src="jquery-ui.js"></script>
  9.     <link rel="stylesheet" href="style.css">
  10. </head>
  11. <body>
  12.  
  13. <p>Start Date: </p>
  14. <input type="text" id="start_date">
  15. <br>
  16. <p>End Date: </p>
  17. <input type="text" id="end_date">
  18. <br>
  19. <script src="main.js"></script>
  20. </body>
  21. </html>
  22.  
  23.  
  24. $(document).ready(function (){
  25.  
  26.     $(function ()
  27.     {
  28.         $("#start_date").datepicker({});
  29.     });
  30.  
  31.     $(function (){
  32.        $("#end_date").datepicker({});
  33.     });
  34.  
  35.     $("#start_date").change(function (){
  36.         startDate=$(this).datepicker('getDate');
  37.         $("#end_date").datepicker("option" , "minDate" , startDate);
  38.     })
  39.  
  40.     $("#end_date").change(function (){
  41.         endDate=$(this).datepicker('getDate' , "maxDate" , endDate);
  42.     })
  43. })
Advertisement
Add Comment
Please, Sign In to add comment