Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Location
    nasik, india
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question date input calendar help??

    Hello,
    I have to include a calendar in my script that will POST selected date.I have
    downloaded jason moons calendar script.The problem is I want all the previous
    dates from todays date should disabled, ie- user can not select yesterdays any date. What modifications could be done? or there is a javascript which has all
    the features i'm looking for? Help me..
    Thanks!
    Naim

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    You need to add a script something like this:-

    <script type = "text/javascript">

    function checkDate() {
    var now = new Date().getTime();
    var d = new Date();
    d.setFullYear(2008,3,22); // Selected date in format YYYY,MM(0-11),DD
    var selectedDate = d.getTime();
    if (selectedDate < now) {
    alert ("Selected date cannot be before today's date!")
    return false;
    }
    return true;
    }

    </script>

    It is your responsibility to die() if necessary….. - PHP Manual

  • #3
    New to the CF scene
    Join Date
    Apr 2008
    Location
    nasik, india
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thats OK philip but if all yesterdays dates automatically get disabled then the procedure will
    be much easy. I am looking for this type of solution ie- user only be able to select todays OR next dates only. Any solution philip ??

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    In fact Moon offers the following:-

    <
    Code:
    script>DateInput('someDate', true)</script>
    
    - - -
    
    <script>
    function validateTheDate() {
       var Today = new Date();
       if (someDate_Object.picked.date < Today) alert('Cannot select a date in the past.');
       else if (someDate_Object.picked.yearValue > 2020) alert('Cannot select dates beyond 2020.');
    }
    </script>

    If you mean that past dates cannot be displayed at all in the select option lists, then I don't see this as practcal, although it mightbe possible with a great deal of code. Not worth the effort in my view.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •