Jquery easyui example of judging when the start time is less than the end time

  • 2020-03-30 02:28:11
  • OfStack

If the start time is less than the end time, please refer to ValidateBox in jquery easyui
All right! Direct up code
 View contents: by time:  
<input class="easyui-datetimebox" style="width: 180px" id="start2" value="${startTime}"> 
<span class="newfont06"> to </span> 
<input class="easyui-datetimebox" style="width: 180px" id="end2" value="${endTime}" validType="md['#start2']"> 
<input name="Submit4" type="button" class="right-button02" value=" check   polling " onclick="query2('${pid}');" id="query"/> 

<script type="text/javascript"> 
var varify;//Used for query validation to verify that the start time is less than the end time
function query2(pid){ 
startTime2 = $('#start2').datetimebox('getValue'); 
endTime2 = $('#end2').datetimebox('getValue'); 
$.messager.alert(' warning ',' The end time is greater than the start time ','warning'); 

$.fn.datebox.defaults.formatter = function(date){//Conversion of time format

var y = date.getFullYear(); 
var m = fullnum(date.getMonth()+1); 
var d = fullnum(date.getDate()); 
return y+'-'+m+'-'+d; 
function fullnum(obj){//For conversions in formats less than 10 months, the Timestamp conversion must be in the format of 2013-01-04
if(Number(obj) < 10){ 
return '0' + obj; 
return obj; 
} } 

$.extend($.fn.validatebox.defaults.rules, {//The validation start time is less than the end time
md: { 
validator: function(value, param){ 
startTime2 = $(param[0]).datetimebox('getValue'); 
var d1 = $.fn.datebox.defaults.parser(startTime2); 
var d2 = $.fn.datebox.defaults.parser(value); 
return varify; 

message: ' End time is greater than start time! ' 

Related articles: