0

对日期比较进行以下验证,当输入无效日期时有效,即结束日期早于开始日期。但问题是,当没有输入日期时,验证也会启动。

如果同时输入了开始日期和结束日期,我只想使用验证。

 $j("#Form1").validate(
    {

        rules:
            {
                content_0$leftcolumn_0$whiteboxplaceholder_0$exportFilterFromActivityDate: {
                    date: true,
                    required: false
                },
                content_0$leftcolumn_0$whiteboxplaceholder_0$exportFilterToActivityDate: {
                    date: true,
                    required: false,
                    isAfterStartDate: "#content_0_leftcolumn_0_whiteboxplaceholder_0_exportFilterFromActivityDate"
                },
                content_0$leftcolumn_0$whiteboxplaceholder_0$exportFilterFromFinalApprovalDate: {
                    date: true,
                    required: false
                },
                content_0$leftcolumn_0$whiteboxplaceholder_0$exportFilterToFinalApprovalDate: {
                    date: true,
                    required: false,
                    isAfterStartDate: "#content_0_leftcolumn_0_whiteboxplaceholder_0_exportFilterFromFinalApprovalDate"
                }
            }
    });
4

1 回答 1

-1

也许先使用条件函数?

if( ($('#dateA').val()!='') && ($('#dateB').val()!='') ){

    $j("#Form1").validate({Validate....});

}
于 2012-11-02T20:22:17.893 回答