我有三個文本框BirthDate
,JoiningDate
& LeavingDate
。出生日期,加入日期和離開日期的有效日期
現在我想的是: -
Joining date
和Leaving date
應不大於Birthdate
Leaving Date
應不大於Joining Date
和BirthDate
我有使用DatePicker。
這裏是JS代碼: -
$(function() {
$("[id$=mainContent_txtdateofbirth], [id$=mainContent_txtdoj], [id$=mainContent_txtdol]").datepicker({
textboxImageOnly: true,
textboxImage: 'images/calendar.png',
changeMonth: true,
changeYear: true,
dateFormat: "yy/mm/dd",
yearRange: "-40:+0",
maxDate: new Date(),
});
});
的三個文本框是: -
<asp:TextBox ID="txtdateofbirth" CssClass="form-control" runat="server" ValidationGroup="AddNew"></asp:TextBox>
<asp:TextBox ID="txtdoj" CssClass="form-control" runat="server" ValidationGroup="AddNew"></asp:TextBox>
<asp:TextBox ID="txtdol" CssClass="form-control" runat="server" ValidationGroup="AddNew"></asp:TextBox>
修訂ASPX CODE: -
<tr>
<td style="vertical-align: top;">
<label class="control-label" for="dob">Date of Birth</label></td>
<td>
<div class="control-group">
<div class="controls">
<asp:TextBox ID="txtdateofbirth" CssClass="form-control" autocomplete="off" runat="server" ValidationGroup="AddNew"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqdob" runat="server" CssClass="error-class" ControlToValidate="txtdateofbirth" ErrorMessage="Please select the date of birth" ValidationGroup="AddNew"></asp:RequiredFieldValidator>
</div>
</div>
</td>
</tr>
<tr>
<td style="vertical-align: top;">
<label class="control-label" for="subject">Date of Join</label></td>
<td>
<div class="control-group">
<div class="controls">
<asp:TextBox ID="txtdoj" Wrap="true" CssClass="form-control" autocomplete="off" runat="server" ValidationGroup="AddNew"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqdoj" CssClass="error-class" runat="server" ControlToValidate="txtdoj" ErrorMessage="Please add the date of joining" ValidationGroup="AddNew"></asp:RequiredFieldValidator>
</div>
</div>
</td>
</tr>
<tr>
<td style="vertical-align: top;">
<label class="control-label" for="subject">Date of Leaving</label></td>
<td>
<div class="control-group">
<div class="controls">
<asp:TextBox ID="txtdol" CssClass="form-control" autocomplete="off" runat="server" ValidationGroup="AddNew"></asp:TextBox>
</div>
</div>
</td>
</tr>
如果用戶嘗試輸入無效日期,您希望用戶體驗如何? – 2015-04-03 14:53:44
@EricHughes:他們應該將消息看作「無效日期」 – BNN 2015-04-03 14:54:34
您想在哪裏放置錯誤消息。在datepickers的輸入字段?或者沒關係? – 2015-04-06 08:28:02