2012-10-08 39 views
1

我有日期的兩個輸入字段:日期選擇器驗證

<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,但我不知道是否有可能。

+0

對於第二部分。比較兩個日期並在ticketForm驗證中第一個大於第二個時返回false –

+0

可能的重複。 http://stackoverflow.com/questions/2287011/jquery-datepicker-validation-message-issue –

回答

-1

請檢查你的jquery jar,它可能是jar之間的衝突離子。 因爲我遇到了同樣的問題,並發現jquery jar之間的衝突離子。