0

i need to check if the user has inputted the correct from - to values for date on my form

for example: (dd/mm/yyyy)

WRONG:

From: 20/12/2012 - To: 11/12/2012

CORRECT:

From: 20/12/2012 - To: 30/12/2012

i need to check the values from the "from" and "to" input fields, so that i can pass the the value to my ajax script, is there anyway to achieve this result using javascript?

telexper
  • 2,381
  • 8
  • 37
  • 66

1 Answers1

1

IF the dates are properly formatted

var BegDT = new Date(st1);
var EndDT = new Date(st2);

You can now subtract BegDT from EndDt and give an error if you don't get a positive number

Sparky
  • 14,967
  • 2
  • 31
  • 45