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');
                }
            });
  • 相关阅读:
    从SmartObject中读取数据
    将数据存储到SmartObject中
    浅识K2 blackpearl中SmartObject
    .net基础
    字符编码
    PowerDesigner教程系列
    Asp.net 2.0(C#)图片存储到数据库和从数据库读取显示
    按回车提交问题:
    .NET设计模式(2):单件模式(Singleton Pattern)
    常用正则表达式收集
  • 原文地址:https://www.cnblogs.com/jpfss/p/7372903.html
Copyright © 2011-2022 走看看