-1

This is my coding from javascript but it did't work

if ( $("#requestDueDate").val().length < CurDate ) {
    alert("Due date should be more than current date");
    setBoolean = false;
    return false; 
}

Thank you.

Tepken Vannkorn
  • 9,648
  • 14
  • 61
  • 86

1 Answers1

1

Convert the string to a date:

// Expect d/m/yyyy
function toDate(s) {
  s = s.split(/\D/g);
  return new Date(s[2],--s[1],s[0]);
}

Then compare to the current date:

function afterNow(s) {
  var now = new Date();
  return +toDate(s) > +now;
}

Try it:

afterNow('9/10/2013'); // false
afterNow('9/10/2031'); // true
RobG
  • 142,382
  • 31
  • 172
  • 209