A simple validation where ToDate should not be less than FromDate.
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