我有日期的兩個輸入字段:日期選擇器驗證
<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,但我不知道是否有可能。
對於第二部分。比較兩個日期並在ticketForm驗證中第一個大於第二個時返回false –
可能的重複。 http://stackoverflow.com/questions/2287011/jquery-datepicker-validation-message-issue –