我有三个文本框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