2010-03-24 64 views
0

問題,我有以下情形:RangeValidator控件日曆擴展項給出野生動物園

到達和離開日期必須與每個日曆擴展表格上選擇,通過2個文本框。

我驗證條目以檢查未選擇今日之前的日期並檢查出發是否在到達之後。我使用了rangevalidator和comparevalidator。

在IE,Firefox和Opera中,它工作正常,在Safari(在Windows上),但是即使在應該接受的條目上,驗證器也會關閉。

它讓我懷疑日期格式dd/MM/yyyy導致Safari的麻煩。

(dd的/ MMMM/yyyy的也給出了相同的煩惱在其他瀏覽器,可能是由於上的UICulture依賴性)

的代碼是:

<tr> 
    <td> 
     <asp:TextBox ID="txtArrive" runat="server"></asp:TextBox> 
     <cc1:TextBoxWatermarkExtender ID="txtArriveWatermarkExt" runat="server" 
      Enabled="True" TargetControlID="txtArrive" WatermarkText="arrival date"> 
     </cc1:TextBoxWatermarkExtender> 
     <cc1:CalendarExtender ID="ArriveCalendarExt" runat="server" 
      CssClass="MyCalendar" Enabled="True" Format="dd/MM/yyyy" 
      TargetControlID="txtArrive"> 
     </cc1:CalendarExtender> 
     <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
      ControlToValidate="txtArrive" ErrorMessage="please select arrival date" 
      Text="*" ValidationGroup="date" Display="none"></asp:RequiredFieldValidator> 
     <asp:RangeValidator ID="RangeValidator1" runat="server" 
      ErrorMessage="please make sure that your arrival date is later than today and not later than a year from now" 
      ControlToValidate="txtArrive" Type="Date" ValidationGroup="date" Text="*"></asp:RangeValidator> 
    </td> 
    <td> 
     <asp:TextBox ID="txtDepart" runat="server"></asp:TextBox> 
     <cc1:TextBoxWatermarkExtender ID="txtDepartWatermarkExt" runat="server" 
      Enabled="True" TargetControlID="txtDepart" WatermarkText="departure date"> 
     </cc1:TextBoxWatermarkExtender> 
     <cc1:CalendarExtender ID="DepartCalendarExt" CssClass="MyCalendar" runat="server" Enabled="True" 
      Format="dd/MM/yyyy" TargetControlID="txtDepart"> 
     </cc1:CalendarExtender> 
     <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
      ControlToValidate="txtDepart" ErrorMessage="Please select departure date" 
      Text="*" ValidationGroup="date"></asp:RequiredFieldValidator> 
     <asp:CompareValidator ID="CompareValidator2" runat="server" 
      ControlToCompare="txtDepart" ControlToValidate="txtArrive" 
      ErrorMessage="your departure date has to be later than your arrival date" 
      Operator="LessThan" Type="Date" Text="*" ValidationGroup="date"></asp:CompareValidator> 
    </td> 
    <td> 
     &nbsp;</td> 
</tr> 

範圍驗證器獲得其值在Page_load

RangeValidator1.MinimumValue = DateTime.Now.AddDays(1).ToShortDateString(); 
RangeValidator1.MaximumValue = DateTime.Now.AddMonths(12).ToShortDateString(); 

後面的代碼是否有人對如何解決這個問題的Safari有什麼建議?

回答

0

將格式屬性設置爲日曆擴展程序的Format =「dd/MM/yyyy」