// 追加表单字段
var param = $("#searchForm").serialize();
param = $.param({‘aaa‘:‘‘}) + ‘&‘ + param;
// 只能正数字输入
<input type="number" onkeyup="this.value=this.value.replace(/\D/g,‘‘)" class="form-control required" />
// js验证字段只能为数字
var regPos = /^\d+(\.\d+)?$/;
if(!regPos.test(content)){
swal("编号只能为数字!");
return false;
}
// 开始不能大于结束时间
function changeDate(){
var start = $("#start").val();;
var end = $("#end").val();
if(start !=‘‘ && end != ‘‘){
if(!tab(start,end)){
swal(‘开始时间必须小于结束时间‘);
return false;
}
return true;
}
}
function tab(date1,date2){
var start = ‘2010-01-01 ‘ + date1;
var end = ‘2010-01-01 ‘ + date2;
var oDate1 = new Date(start);
var oDate2 = new Date(end);
if(oDate1.getTime() < oDate2.getTime()){
return true;
} else {
return false;
}
}
// checkbox默认选中已有数据
<input type="checkbox" value="1" name="week" id="checkbox1" <c:if test="${fn:contains(entity.week,‘1‘)==true}">checked</c:if>/>周一
<input type="checkbox" value="2" name="week" id="checkbox2" <c:if test="${fn:contains(entity.week,‘2‘)==true}">checked</c:if>/>周二
<input type="checkbox" value="3" name="week" id="checkbox3" <c:if test="${fn:contains(entity.week,‘3‘)==true}">checked</c:if>/>周三
// radio默认选中后台传入数据
<input type="radio" name="status" <c:if test="${entity.status==false}" >checked</c:if> value="0" class="required"/>无
<input type="radio" name="status" <c:if test="${entity.status==true}" >checked</c:if> value="1" class="required"/>有
// 进入页面默认radio不可编辑
$(document).ready(function () {
$("input[name=‘status‘]").each(function(){
if($(this).attr("checked") != ‘checked‘){
$(this).attr("disabled", "disabled");
}
});
})
mybatis
// kwyword模糊查多段
id LIKE CONCAT(CONCAT(‘%‘, #{keyword}), ‘%‘) or name LIKE CONCAT(CONCAT(‘%‘, #{keyword}), ‘%‘)
// 根据开始结束时间查询
<if test="beginTime != null ">
and beginTime > DATE_FORMAT(#{beginTime},‘%Y-%m-%d 00:00:00‘)
</if>
<if test="endTime != null ">
and endTime < DATE_FORMAT(#{endTime},‘%Y-%m-%d 23:59:59‘)
</if>
原文:https://www.cnblogs.com/webster1/p/13177557.html