View Full Version : JS date range validation ??

02-22-2007, 08:51 PM
I have two date field viz from-date and to-date
and i want to validate that from-date should be less than or equal to to-date
using javascript.
Note: date field should be in yy-mm-dd format
How is that possible ?
Please help me..
Thanks in advance..

02-22-2007, 09:22 PM
You can split the date into pieces then compare them part by part. Itíll be harder if you want to compare 1900 years with 2000 years in a yy format though.

var fromDateSplit = fromDate.split("-");
var toDateSplit = toDate.split("-");

Tutorial: http://www.pageresource.com/jscript/jstring2.htm*
* Uses some poor practice and outdated code.