javascript - Validation in Java script for the date in asp.net -


i have java script in have validation date i.e todate >= fromdate.
below script. need validate dates user select fromdate-todate. in advance.

// <reference path="http://localhost:5378/scripts/jquery-1.4.1-vsdoc.js" />  var pubreportname = ""; 

/* dom loaded function */

 $(function () {  pubreportname = ""; $("#bttnprint").click(printreport_click);  $('#txtfrdate').val(''); $('#txttodate').val('');  $("#txtfrdate").datepicker({ dateformat: 'dd/mm/yy' }); $("#txttodate").datepicker({ dateformat: 'dd/mm/yy' });  $('#reportleftdiv li').click(function () {     // remove active classes     $('#reportleftdiv li').removeclass('active');      $(this).addclass('active');  }); 

});

function printreport_click() {    var repname = $('#reportleftdiv li.active').attr('id');  if (repname == undefined || repname == null) {     alert("please choose report name");     return false; }  var reportparameters = new array(); var stdt = $('#txtfrdate').val(); var enddt = $('#txttodate').val();  reportparameters.push({ reportname: "/lisreportproject/" + repname, paraname: "pstartdate", paravalue: stdt }); reportparameters.push({ reportname: "/lisreportproject/" + repname, paraname: "penddate", paravalue: enddt });     sessionstorage.setitem('reportparameters', json.stringify(reportparameters)); //   showhideprocessingdivs('show');    fnprintresult();    var data1 = json.stringify({ reportparameters: reportparameters });    $.ajax({     cache: false,     type: "post",     url: "wcf/labstatusservice.svc/setsessionvalues",     data: data1,     contenttype: "application/json; charset=utf-8",     datatype: "json",     processtype: false,     success: fnprintresult,     failure: onerrorfunction }); 

}

function fnprintresult()  {  $.printpreview("lab statistics report", "../printpreview.aspx"); 

}

function onerrorfunction(result) { //document.getelementbyid('divwait').style.visibility = "hidden" //showhideprocessingdivs('show'); popupmessage("error", result.d, 'alert'); 

}

function showhideprocessingdivs(showhide) { switch (showhide) {     case 'show':         $('#divwait').removeclass('#overlay').addclass('').show();         if ($('#processing').hasclass("processing"))             $('#processing').removeclass("processing");          $('#processing').addclass("processing").show();          break;     case 'hide':         $('#divwait').hide();         $('#processing').hide();         break; } 

}

fiddle

javascript

$('#txtfrom').datepicker({     inline: true,     dateformat: 'dd/mm/yy' }); $('#txtto').datepicker({     inline: true,     dateformat: 'dd/mm/yy' });  function com() {     var start = $('#txtfrom').val();     var = $('#txtto').val();     if (new date(to) >= new date(start)) {         $('#result').text("to date greater or equal start");     }else{         $('#result').text("to date less start");     } }   

there 2 alternates.. either user might forced select to date greater or same from date directly using jquery onclosed function within datepicker , other using javascript date object


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -