Validate Date of Birth
protected void Page_Load(object sender, EventArgs e)
{
rvSearchDOB.MaximumValue = DateTime.Now.ToString("d");
}
<asp:TextBox runat="server" ID="txtSearchDOB" /> <asp:Image ImageUrl="~/Images/calender_btn.png"
runat="server" ID="imgCal" ImageAlign="AbsMiddle" />
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtSearchDOB"
Format="d" PopupButtonID="imgCal" />
<asp:CompareValidator ErrorMessage="Invalid date format. Use (mm/dd/yyyy)" Display="None" ID="cvSearchDOB"
ControlToValidate="txtSearchDOB" Operator="DataTypeCheck" Type="Date" runat="server" ValidationGroup="grpSearchSubmit" />
<ajaxtoolkit:ValidatorCalloutExtender ID="vcSearchDOB" runat="server" TargetControlID="cvSearchDOB"
PopupPosition="TopLeft" Enabled="True" />
<asp:RangeValidator ID="rvSearchDOB" runat="server" ControlToValidate="txtSearchDOB"
MinimumValue="1/1/1900" MaximumValue="1/1/2100" Type="Date" Text="Invalid Date"
Display="None" ValidationGroup="grpSearchSubmit" />
<ajaxtoolkit:ValidatorCalloutExtender ID="vcretxtSearchDOB" runat="server" TargetControlID="rvSearchDOB"
PopupPosition="TopLeft" Enabled="True" />
No comments:
Post a Comment