我使用CompareValidator
以确保在开始日期之前无法设置完成日期。到目前为止,没有快乐,即使输入的开始日期是在完成日期之前设置的,它也会提示错误信息?这里是我的代码:Asp.NET - 使用CompareValidator验证开始日期和结束日期
<td class="question">
Finish Date and Time
</td>
<td>
<asp:TextBox runat="server" ID="TxtFinish" CssClass="answer" MaxLength="50" Width="100px"/>
<span class="mandatory">*</span>
<obout:Calendar ID="Calendar2" runat="server"
DatePickerMode="true"
TextBoxId="TxtFinish"
ShowTimeSelector="true"
TextSelectTime="Set Time">
</obout:Calendar>
<asp:CompareValidator id="CompareValidator1" runat="server"
ControlToCompare="txtDate" cultureinvariantvalues="true" display="Dynamic" enableclientscript="true" ControlToValidate="TxtFinish"
ErrorMessage="Start date must be earlier than finish date" type="Date"
setfocusonerror="true" Operator="GreaterThanEqual" text="The Start date must be set before the finish date"></asp:CompareValidator>
任何帮助将感激地收到。
txtDate是我的开始日期,我应该说道歉。 – user1259076
我很高兴为您效劳user1259076 –