zoukankan      html  css  js  c++  java
  • easyui 时间段校验,开始时间小于结束时间,并且时间间隔不能超过30天


    //
    对easyui datetimebox的验证,开始时间要小于结束时间

    function validateDateTime(beginTimeId,endTimeId,whichTimeId)
    {
    console.log(
    "hello world");
    var v1=$('#'+beginTimeId).datetimebox("getValue");
    var date1 = new Date(v1);
    var v2=$('#'+endTimeId).datetimebox("getValue");
    var date2 = new Date(v2);

    </span><span style="color: #0000ff;">if</span>(v1==''||v2==''<span style="color: #000000;">)
    {
        </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">true</span><span style="color: #000000;">;
    }    
    console.log(date1);
    console.log(date2);
    </span><span style="color: #0000ff;">if</span>(date1&lt;<span style="color: #000000;">date2)
    {
        console.log(date1</span>+"&lt;"+<span style="color: #000000;">date2);
        </span><span style="color: #0000ff;">var</span> diff=<span style="color: #000000;">DateDiff(date1,date2);
        </span><span style="color: #0000ff;">if</span>(diff&gt;30<span style="color: #000000;">)
        {
            $.messager.alert(</span>'提示','时间段不能超过30天!'<span style="color: #000000;">);
            $(</span>'#'+whichTimeId).datetimebox("setValue",""<span style="color: #000000;">);
        }
        </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">true</span><span style="color: #000000;">;
    }
    console.log(date1</span>+"!&lt;"+<span style="color: #000000;">date2);
    </span><span style="color: #0000ff;">try</span><span style="color: #000000;">{
        $(</span>'#'+whichTimeId).datetimebox("setValue",""<span style="color: #000000;">);
    }</span><span style="color: #0000ff;">catch</span><span style="color: #000000;">(e){
    }
    </span><span style="color: #0000ff;">try</span><span style="color: #000000;">{
        $(</span>'#'+whichTimeId).datebox("setValue",""<span style="color: #000000;">);
    }</span><span style="color: #0000ff;">catch</span><span style="color: #000000;">(e){
    }
    
    $.messager.alert(</span>'提示','开始时间要小于结束时间!'<span style="color: #000000;">);
    
    </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">false</span><span style="color: #000000;">;       
    

    }

    示例:

            $('#fssjFrom1').datetimebox({
                onHidePanel: function(date){
                    validateDateTime('fssjFrom1','fssjTo1','fssjFrom1');
                }
            });
            $('#fssjTo1').datetimebox({
                onHidePanel: function(date){
                    validateDateTime('fssjFrom1','fssjTo1','fssjTo1');
                }
            });
  • 相关阅读:
    python 3 day1(上)
    JMeter (一) Thread Group
    TC-001下载并简单使用Python
    SQL Server ->> 谈SQL Server数据库大表迁移
    SQL Server ->> 记Alwayson高可用副本同步失败后续恢复的性能调优争议
    SQL Server ->> AlwaysOn高可用副本同步失败
    SQL Server ->> AlwaysOn 监控脚本
    Linux ->> Source命令
    PSD 转化成 HTML
    笔试
  • 原文地址:https://www.cnblogs.com/jpfss/p/7372903.html
Copyright © 2011-2022 走看看