【问题标题】:datepicker validation日期选择器验证
【发布时间】:2012-09-28 12:19:13
【问题描述】:

我有两个日期输入字段:

<input type='text' id='txtLeaveDate' name='txtLeaveDate' class='date'  /> 
<input type='text' id='txtArriveDate' name='txtArriveDate' class='date' /> 

验证脚本:

$().ready(function() {
// validate the comment form when it is submitted

// validate signup form on keyup and submit
$('#ticketform').validate({
    rules: {
        txtLeaveDate: 'required',
                    txtArriveDate: 'required'

    },
    messages: {
        txtLeaveDate: 'Required!',
        txtArriveDate: 'Required!'

    }
});
});
</script>   

和日期选择器脚本:

    $('.date').datepicker({
        dateFormat:'dd.mm.yy',
        onClose: function () {
            $('.date').valid();
        }

    });

但我总是收到错误消息:“必填”。

另外,我想这样做#txtArriveDate 不能早于#txtLeaveDate,但我不知道是否可能。

【问题讨论】:

标签: jquery validation datepicker


【解决方案1】:

看看这个jQuery Datepicker validation 这个文件中有很多类型的验证可用。随心所欲

【讨论】:

    【解决方案2】:

    因为我的输入有class='date',所以它已经过验证并且是错误的。我有一条消息 必填!对于所有的问题。这就是原因。

    第二部分我使用了这个教程:http://jquerybyexample.blogspot.com/2012/01/end-date-should-not-be-greater-than.html

    【讨论】:

      【解决方案3】:

      请检查您的 jquery jar,可能是由于 jar 之间的冲突。 因为我遇到了同样的问题并发现了 jquery jars 之间的冲突。

      【讨论】:

        猜你喜欢
        • 2022-01-22
        • 2011-02-06
        • 1970-01-01
        • 1970-01-01
        • 2015-01-29
        • 2023-03-25
        • 2018-09-28
        • 2021-02-13
        相关资源
        最近更新 更多