首页 > 其他 > 详细

记不住系列

时间:2021-01-04 11:54:12      阅读:17      评论:0      收藏:0      [点我收藏+]

// 追加表单字段
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");
    }
  });
})

// 获取redio值

function GetRadioValue(RadioName){
  var obj;
  obj=document.getElementsByName(RadioName);
  if(obj!=null){
    var i;
    for(i=0;i<obj.length;i++){
      if(obj[i].checked){
        return obj[i].value;
      }
    }
  }
  return null;
}

// 头标题醒目

<div class="panel panel-primary">
<div class="panel-heading">

mybatis
// kwyword模糊查多段
id LIKE CONCAT(CONCAT(‘%‘, #{keyword}), ‘%‘) or name LIKE CONCAT(CONCAT(‘%‘, #{keyword}), ‘%‘)
// 根据开始结束时间查询
<if test="beginTime != null ">
  and beginTime &gt; DATE_FORMAT(#{beginTime},‘%Y-%m-%d 00:00:00‘)
</if>
<if test="endTime != null ">
  and endTime &lt; DATE_FORMAT(#{endTime},‘%Y-%m-%d 23:59:59‘)
</if>

<setting name="logImpl" value="STDOUT_LOGGING" />

 

// 当月头一天和最后一天

function getCurrentMonthFirst(){
    var date = new Date();
    date.setDate(1);
    var month = parseInt(date.getMonth()+1);
    var day = date.getDate();
    if (month < 10) {
        month = ‘0‘ + month
    }
    if (day < 10) {
        day = ‘0‘ + day
    }
    return date.getFullYear() + ‘-‘ + month + ‘-‘ + day;
}
function getCurrentMonthLast(){
    var date=new Date();
    var currentMonth=date.getMonth();
    var nextMonth=++currentMonth;
    var nextMonthFirstDay=new Date(date.getFullYear(),nextMonth,1);
    var oneDay=1000*60*60*24;
    var lastTime = new Date(nextMonthFirstDay-oneDay);
    var month = parseInt(lastTime.getMonth()+1);
    var day = lastTime.getDate();
    if (month < 10) {
        month = ‘0‘ + month
    }
    if (day < 10) {
        day = ‘0‘ + day
    }
    return date.getFullYear() + ‘-‘ + month + ‘-‘ + day;
}

记不住系列

原文:https://www.cnblogs.com/webster1/p/13177557.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!