A simple validation where ToDate should not be less than FromDate.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | function ValidateDate() { try { var fromDate = document.getElementById( "txtFromDate" ).value; var toDate = document.getElementById( "txtDateTo" ).value; var fromD = fromDate.split( "-" ); var toD = toDate.split( "-" ); //yyyy-mm-dd format var date1 = new Date(fromD[0], fromD[1], fromD[2]); var date2 = new Date(toD[0], toD[1], toD[2]); if (date2 < date1) { alert( "To Date should not be less than From Date" ); return false ; } else return true ; } catch (err) { return false ; } } |
Works in following
0 comments:
Post a Comment