how to enter the textbox value only aceptin date value not accept number and special characters

Posted by Venky.Net under ASP.NET on 9/10/2012 | Points: 10 | Views : 8565 | Status : [Member] | Replies : 1
i have one textbox.this text box already having the ajaxcalender control but i want ouput only accepting date format dataonly.


Posted by: Vasanthmvp on: 9/11/2012 [Member] Starter | Points: 25

Hi, You can use validation controls to check with the string format entered in the text box.
Here is a sample example:


Date of birth: <asp:TextBox ID="t1" runat="server" /><br />
<asp:RequiredFieldValidator ID="req1" runat="server" ErrorMessage="Enter DateOfBirth !" ControlToValidate="t1" ForeColor="Red" />
<asp:CompareValidator ID="comp1" runat="server" ErrorMessage="Not in Date format(MM/DD/YYYY)"
ControlToValidate="t1" Type="Date" Operator="DataTypeCheck" ForeColor="Red" /> <br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />


Awesome Coding !! :)

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response