2012-07-13 76 views
0

我對asp.net中的日期和日期有如下選擇標準。我想要包含日期格式驗證和comaprision驗證。我如何包括下面的要求在asp.net驗證子,它按鈕點擊?在asp.net中對TO和FROM日期進行日期驗證

  1. 如果用戶選擇TO或FROM日期,他必須同時選擇TO和FROM。
  2. 如果TO日期小於FROM日期,則應顯示錯誤消息。

enter image description here

+0

@Avd據我所知'compareValidator'是用於精確比較和'RequiredField'我不知道如何利用。 @ V4Vendetta正在研究它。 – Pratik 2012-07-13 07:54:02

回答

0

檢查格式,使用CompareValidator

<asp:CompareValidator Operator="DataTypeCheck" Type="Date" ... 

要檢查結束日期開始後,嘗試另一種CompareValidator(這應該 - 未測試)

<asp:CompareValidator Operator="GreaterThan" 
    ControlToValidate="txtEnd" 
    ControlToCompare="txtStart" 
    Type="Date" 

要檢查您的更復雜的要求,請使用CustomValidator

<asp:CustomValidator