I have three textboxes for BirthDate
, JoiningDate
& LeavingDate
.
Now what I want is:-
Joining date
and Leaving date
should not be greater than Birthdate
Leaving Date
should not be greater than Joining Date
and BirthDate
I have used the DatePicker.
Here is the JS code:-
$(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(),
});
});
The three textboxes are:-
<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>
UPDATED 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>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…