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. Web Development
  3. JavaScript
  4. datepicker on button click not working

datepicker on button click not working

Scheduled Pinned Locked Moved JavaScript
help
1 Posts 1 Posters 2 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.
  • D Offline
    D Offline
    Dhyanga
    wrote on last edited by
    #1

    I have a datepicker which needs to have its date disabled only on button click. below is the code on button click. I actually wanted to use returned data but for now to check I am only using availableDates for blocking. Please help.

    posting.done(function (data) {
    var date = new Date();
    var temp = data.split(",");
    alert(data);
    var year = (new Date).getFullYear();
    $("#datepicker").datepicker();
    var availableDates = ['01-25-2021'];
    $("#datepicker").datepicker({
    beforeShowDay: function (d) {
    var dmy = (d.getMonth() + 1);
    if (d.getMonth() < 9)
    dmy = "0" + dmy;
    dmy += "-";
    if (d.getDate() < 10) dmy += "0";
    dmy += d.getDate() + "-" + d.getFullYear();
    if ($.inArray(dmy, availableDates) != -1) {
    return [false];
    } else {
    return [true];
    }
    }
    });
    })

    Dhyanga

    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