zoukankan      html  css  js  c++  java
  • js

    //时间校验
    function isDate(date){
    var message="请输入正确的日期格式:YYYY-MM-DD"
    var result = date.match(/^(d{1,4})(-|/)(d{1,2})2(d{1,2})$/);
    if(result==null){
    alert(message);
    return false;
    }
    var newDate = new Date(result[1], result[3]-1, result[4]);
    var isRight = newDate.getFullYear()==result[1]&&(newDate.getMonth()+1)==result[3]&&newDate.getDate()==result[4] ;
    if(!isRight){
    alert(message) ;
    }
    return isRight ;
    }

    //比较两个时间的大小
    function dateCompare(asStartDate,asEndDate){
    var miStart = Date.parse(asStartDate.replace(/-/g, '/'));
    var miEnd = Date.parse(asEndDate.replace(/-/g, '/'));
    return (miEnd-miStart)/(1000 * 24 * 3600);
    }

    //对数据进行合法性校验
    function doInputChange(obj,rowNo){
    var name =obj.name;
    if(name=="txDate"+rowNo){
    if(!isDate(obj.value.trim(),true)){
    obj.focus();
    return false;
    }
    return true;
    }

    if(name=="vchNo"+rowNo){
    var val=obj.value;
    if(val.trim().length<=0){
    alert("凭证号不能为空 ");
    obj.focus();
    return false;
    }
    return true;
    }
    if(name=="opKMH"+rowNo){
    var val=obj.value;
    if(val.trim().length<=0){
    alert("对方科目不能为空 ");
    obj.focus();
    return false;
    }
    return true;
    }
    if(name=="memo"+rowNo){
    var val=obj.value;
    if(val.trim().length<=0){
    alert("摘要不能为空 ");
    obj.focus();
    return false;
    }
    return true;

    }
    if(name=="amount"+rowNo){
    var val=obj.value;
    if(val.trim().length<=0){
    alert("金额不能为空 ");
    obj.focus();
    return false;
    }
    if(val<=0){
    alert("金额大于0 ");
    obj.focus();
    return false;
    }
    return true;

    }
    return true;
    }

  • 相关阅读:
    动态规划____类数字三角形
    动态规划____编辑距离
    123
    pair queue____多源图广搜
    JAVA练习01
    leetcode — binary-tree-maximum-path-sum
    leetcode — best-time-to-buy-and-sell-stock-iii
    leetcode — best-time-to-buy-and-sell-stock-ii
    leetcode — best-time-to-buy-and-sell-stock
    leetcode — triangle
  • 原文地址:https://www.cnblogs.com/lvxiaowei/p/4310814.html
Copyright © 2011-2022 走看看