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
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){
if(varify){
startTime2 = $('#start2').datetimebox('getValue');
endTime2 = $('#end2').datetimebox('getValue');
window.location.href="listPagingArticle?pid="+pid+"&pageNumber=1&start="+startTime2+"&end="+endTime2;
}else{
$.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;
}else{
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);
varify=d2>d1;
return varify;
},
message: ' End time is greater than start time! '
}
})
</script>