-1

I have a problem here, I'm working on a project here I have to limit the date value to not save the date if the value inserted was yesterday or so on.(e.g. from the beginning of the universe to Jan. 13 2016).

I'm using php and javascript. This is the code:

function date(){
var present = new Date();
var day = today.getDate();
var month = today.getMonth()+1; //January is 0!
var year = today.getFullYear();

if(day<10) {
    day='0'+day
} 

if(month<10) {
    month='0'+month
} 
}
today = month+'/'+day+'/'+year;
document.write(today);
Marcinek
  • 2,144
  • 1
  • 19
  • 25
Kristian
  • 1
  • 4
  • Hi and welcome to SO, I'd strongly recommend that you have a look at [the tour](http://stackoverflow.com/tour) to get a better idea of how SO works and what kinds of questions are appropriate. As your question is now, it's rather vague and lacks code, show us what you have tried and included anything that didn't work. (Error codes and what not). - Also, be careful to only tag your question with relevant tags, as I see it, your question has little to do with Java. – Epodax Jan 14 '16 at 07:57
  • @Epodax I forgot to include my code sorry, I have just edited my question with the code. – Kristian Jan 14 '16 at 08:01

1 Answers1

0

use datepicker and assign minDate:0 to it like as follow:

$(function () {
   $("#completion_date").datepicker({
     minDate: 0,
     dateFormat: 'dd/mm/yy',
   });
});

apply this function on the date field onclick="function name()". Hope this will do. The minDate:0 blocks the date before today.

nerdyDev
  • 376
  • 3
  • 15