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;
    }

  • 相关阅读:
    nginx能访问html静态文件但无法访问php文件
    LeetCode "498. Diagonal Traverse"
    LeetCode "Teemo Attacking"
    LeetCode "501. Find Mode in Binary Search Tree"
    LeetCode "483. Smallest Good Base" !!
    LeetCode "467. Unique Substrings in Wraparound String" !!
    LeetCode "437. Path Sum III"
    LeetCode "454. 4Sum II"
    LeetCode "445. Add Two Numbers II"
    LeetCode "486. Predict the Winner" !!
  • 原文地址:https://www.cnblogs.com/lvxiaowei/p/4310814.html
Copyright © 2011-2022 走看看