Michiel Sallaets
Michiel Sallaets

Reputation: 1

Datepicker not working (ASP.NET MVC)

I try the code on this website: http://www.dotnetfunda.com/articles/show/3009/multiple-date-picker-functionality-in-jquery

When I try this code, there is nothing that works. I also looked at other tutorial it's always the same result. An empty textbox or a blank page.

<html>
<head>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
</head>

<script>
 $(function () {
   $("#datepicker").datepicker({
     numberOfMonths: 4,
     showButtonPanel: true
   });
  });
</script>
  
<body> 
 <p>Date: <input type="text" id="datepicker"/></p>
</body>

</html>

The code works with code snippet...

Upvotes: 0

Views: 938

Answers (1)

Rahul Raut
Rahul Raut

Reputation: 633

As mentioned in comments yes it will work; as script is going to run on document.ready(). Correcting my answer; but still it is good practice to keep script tags bottom of the html after body.

  <html>
  <head>
  <link rel="stylesheet" href="//code.jquery.com//ui//1.11.2//themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com//jquery-1.10.2.js"></script>
  <script src="//code.jquery.com//ui//1.11.2//jquery-ui.js"></script>
  </head> 
  <body> 
   <p>Date: <input type="text" id="datepicker"/></p>
  </body>
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
  <script>
    $(function () {
      $("#datepicker").datepicker({
        numberOfMonths: 4,
        showButtonPanel: true
      });
     });
   </script>
  </html>

Upvotes: 1

Related Questions