Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Another JQuery datepicker question

Another JQuery datepicker question

Scheduled Pinned Locked Moved .NET (Core and Framework)
asp-nettutorialquestioncsharpjavascript
6 Posts 2 Posters 13 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • pkfoxP Offline
    pkfoxP Offline
    pkfox
    wrote on last edited by
    #1

    Hi all, I copied the html shown below from a tutorial on how to use the JQuery datepicker. If I run it in Visual Studio ( it's part of an MVC project) it works perfectly. I want to add the functionality of this to my personal project which is a net core Web app I've tried adding the link and script references to _layout.cshtml and set the id of my date properties to "datepicker" but I don't see the datepicker popup. Anyone know what I'm doing wrong or missing ?

    @{
    ViewBag.Title = "Index";
    }
    @model JQueryDatePicker.Models.Customer
    @using (Html.BeginForm("index", "home"))
    {

        @Html.LabelFor(c => c.JoinDate)     @Html.TextBoxFor(c => c.JoinDate, new { id = "datepicker" })
    
    
      
    
    
        
            Submit
    

    }

    $("#datepicker").datepicker({
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 2,
        dateFormat: 'dd-mm-yy'
    });
    

    "I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP

    pkfoxP Richard DeemingR 2 Replies Last reply
    0
    • pkfoxP pkfox

      Hi all, I copied the html shown below from a tutorial on how to use the JQuery datepicker. If I run it in Visual Studio ( it's part of an MVC project) it works perfectly. I want to add the functionality of this to my personal project which is a net core Web app I've tried adding the link and script references to _layout.cshtml and set the id of my date properties to "datepicker" but I don't see the datepicker popup. Anyone know what I'm doing wrong or missing ?

      @{
      ViewBag.Title = "Index";
      }
      @model JQueryDatePicker.Models.Customer
      @using (Html.BeginForm("index", "home"))
      {

          @Html.LabelFor(c => c.JoinDate)     @Html.TextBoxFor(c => c.JoinDate, new { id = "datepicker" })
      
      
        
      
      
          
              Submit
      

      }

      $("#datepicker").datepicker({
          changeMonth: true,
          changeYear: true,
          numberOfMonths: 2,
          dateFormat: 'dd-mm-yy'
      });
      

      "I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP

      pkfoxP Offline
      pkfoxP Offline
      pkfox
      wrote on last edited by
      #2

      I added type="datetime" to the anonymous type and tweaked the script to the below and it worked. The added bonus is it works for all datetime properties

      $(document).ready(function () {
      $('input[type=datetime]').datepicker({
      numberOfMonths: [1, 1],
      dateFormat: "dd-M-yy",
      changeMonth: true,
      changeYear: true
      });
      });

      @Html.TextBoxFor(m => m.DateUsed,new {type="datetime"})

      "I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP

      1 Reply Last reply
      0
      • pkfoxP pkfox

        Hi all, I copied the html shown below from a tutorial on how to use the JQuery datepicker. If I run it in Visual Studio ( it's part of an MVC project) it works perfectly. I want to add the functionality of this to my personal project which is a net core Web app I've tried adding the link and script references to _layout.cshtml and set the id of my date properties to "datepicker" but I don't see the datepicker popup. Anyone know what I'm doing wrong or missing ?

        @{
        ViewBag.Title = "Index";
        }
        @model JQueryDatePicker.Models.Customer
        @using (Html.BeginForm("index", "home"))
        {

            @Html.LabelFor(c => c.JoinDate)     @Html.TextBoxFor(c => c.JoinDate, new { id = "datepicker" })
        
        
          
        
        
            
                Submit
        

        }

        $("#datepicker").datepicker({
            changeMonth: true,
            changeYear: true,
            numberOfMonths: 2,
            dateFormat: 'dd-mm-yy'
        });
        

        "I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        pkfox wrote:

        <script src="//code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>

        That's a really old version of jQuery, which no longer receives patches. The current version is 3.6.0; you only need to stick to the v1 branch if you need to support Internet Explorer 6-8, Opera 12, or Safari 5. Browser Support | jQuery[^]


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        pkfoxP 1 Reply Last reply
        0
        • Richard DeemingR Richard Deeming

          pkfox wrote:

          <script src="//code.jquery.com/jquery-1.10.2.js" type="text/javascript"></script>

          That's a really old version of jQuery, which no longer receives patches. The current version is 3.6.0; you only need to stick to the v1 branch if you need to support Internet Explorer 6-8, Opera 12, or Safari 5. Browser Support | jQuery[^]


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          pkfoxP Offline
          pkfoxP Offline
          pkfox
          wrote on last edited by
          #4

          Thanks Richard - as I said I copied it from a tutorial for use in a personal project so no big deal - I'll update the links though - do I need to update the css also ?

          "I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP

          Richard DeemingR 1 Reply Last reply
          0
          • pkfoxP pkfox

            Thanks Richard - as I said I copied it from a tutorial for use in a personal project so no big deal - I'll update the links though - do I need to update the css also ?

            "I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP

            Richard DeemingR Offline
            Richard DeemingR Offline
            Richard Deeming
            wrote on last edited by
            #5

            The jQuery UI reference looks OK - the latest version is 1.12.1, so you're not too far behind. :)


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

            pkfoxP 1 Reply Last reply
            0
            • Richard DeemingR Richard Deeming

              The jQuery UI reference looks OK - the latest version is 1.12.1, so you're not too far behind. :)


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              pkfoxP Offline
              pkfoxP Offline
              pkfox
              wrote on last edited by
              #6

              :thumbsup:

              "I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups