calendar - How to validate From and To dates in JQuery? -
have validate 2 dates in aspx page using ajaxcontroltoolkit calendar extender.
following code:
function datevalidation() { alert($("#txtfromdup").val() + "\n" + $("#txttodup").val()) var fromdate = date.parse($("#txtfromdup").val()); var todate = date.parse($("#txttodup").val()); alert(fromdate + "\n" + todate); var timediff = todate - fromdate; var daysdiff = math.floor(timediff / (1000 * 60 * 60 * 24)); alert(daysdiff); if (daysdiff > 30) { alert('from date shouldn\'t less date.'); return false; } else return true; }
its not validating properly.
please me resolve this.
i'd like
var startdate = new date( "2015-07-04"); var enddate = new date( "2015-08-11"); var timediff = math.abs(enddate.gettime() - startdate.gettime()); var diffdays = math.ceil(timediff / (1000 * 3600 * 24)); alert(diffdays); //pseudo code: if (diffdays > 30){ //set timeformat = "30days" alert('from date shouldn\'t less date.'); }else{ alert('valid.'); }
Comments
Post a Comment