0

I am trying to find a date picker that can show dates to select starting current date so that the users don't select the past date and I need not worry about validating. I am not sure if this will show the correct date for any one from any place. I found some plugins but none of it has this option.

I found this http://jqueryui.com/demos/datepicker/#min-max but the restrict range option starts with 10-15 days before current date. I am expecting the date format to be 2010-06-28 as I have my other code on the site works based on this format.

I am trying to find a best example for php/mysql/jquery crud with these options After a user logs in, I want to show his/her current list of items with "delete item, update/modify item, add a new item. I have a page for the "add new item" so the user can be navigated to that page and he can add a new item by filling a name, date and some more info.

Please help me out. Sorry if I cannot post questions asking for info without giving any code examples.

regards

JDesigns
  • 2,284
  • 7
  • 25
  • 39
  • You should always validate server side regardless of what control you use on the client side--just in case. – Rob Jun 28 '10 at 16:11
  • rob, I did not get you. When I said validate I meant not worrying about checking if the date selected is past date or not. I am assuming that if I can show only dates starting current date, i can avoid this validation. Please advise me if I got your comment wrong. – JDesigns Jun 28 '10 at 16:17
  • i am just trying to store the selection. Right now I tried some drop down with start and end date option but that allows users to select past dates so in the other part of the site I will not able to show this entry because it falls before today's date – JDesigns Jun 28 '10 at 16:22
  • Rob is saying that even if your js doesn't allow that, there is nothing stopping a user from editing the form on your page or just manually submitting wonky data to your server. You need to do some validation on the server side just in case – Nathan Hess Jun 28 '10 at 16:23
  • @threendib, thank you. that helps. I was just trying that one. I used the plugin that I mentioned and that's doing what I want except the manual typing of the date. I guess I cannot make that read only but I am trying to check if entered is >= todays date and see if that helps. – JDesigns Jun 28 '10 at 18:23

1 Answers1

1

The jQueryUI datepicker that you mentioned will do what you need it to. Set the options for the instance using the options below:

$(document).ready(function() {
    $("#datepicker").datepicker({
        minDate: +0,
        dateFormat: 'yy-mm-dd'
    });
});

This will start the date options with today and format the date as you specified the format needed to be. All you need to do is make sure the selector is correct by setting the correct ID for the input field.

Joseph
  • 1,988
  • 14
  • 21
  • @joseeph, I was just trying this. I did not see the source code from that link before. I will play with that code and see. thanks for the help. – JDesigns Jun 28 '10 at 16:34
  • This works. I am checking the entered date to see if its today or greater than todays date and then store it in db. I guess it will work fine. Any idea about my other question? If i can get some links to see examples I can go from there. – JDesigns Jun 28 '10 at 18:55
  • I am not sure what the "other question" is. I had a rough enough time ferreting out this one. :) – Joseph Jun 28 '10 at 19:19
  • I am trying to find a best example for php/mysql/jquery crud with these options After a user logs in, I want to show his/her current list of items with "delete item, update/modify item, add a new item. I have a page for the "add new item" so the user can be navigated to that page and he can add a new item by filling a name, date and some more info. – JDesigns Jun 28 '10 at 20:00
  • 1
    See the following: http://stackoverflow.com/questions/1148388/crud-for-mysql-and-php, http://stackoverflow.com/questions/131718/common-crud-functions-in-php, and http://stackoverflow.com/questions/2020951/simple-php-crud-generator – Joseph Jun 28 '10 at 20:09