Click here to Skip to main content
14,924,336 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
how to validate calendar extender on a has to take only date i have use filtered control and gave valid char as no's is working fine but if we press no's in that text box it is taking i have to avoid that and it has to allow only date to be selected from that calendar...pls reply

try this:-

There is a soluton that works across the browsers. Put
onKeyPress = "javascript: return false;" onPaste = "javascript: return false;"
in your textbox. That way, even the textbox is enabled, the user will not be able to modify the data.

Please refer the links for more details:-[^][^][^]

I hope this will help you out.

Kiirrii 22-Feb-12 0:08am
onKeyPress = "javascript: return false;"
sweet and simple thanks...
Varun Sareen 22-Feb-12 0:09am
your welcome dear
Dear disable the textbox so that nobody can access textbox
Kiirrii 21-Feb-12 23:45pm
if u make it as disable calender wil not come....
ashumeerut 12-Aug-13 1:52am
backspace is working, problem
Varun Sareen 21-Feb-12 23:58pm
absolutely right
Kiirrii 21-Feb-12 23:48pm
Used Calender Extender dude on that textbox disable not works..

I think you should set your textboxt to read only mode....
If you are using ajax toolkit then...

See this sample code:

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<td align="left">
   Admission Date:
<td align="left">
  <asp:textbox id="txtAdmissionDate" runat="server" maxlength="10" readonly="true"> 
  <cc1:calendarextender popupbuttonid="imgDatepicker" id="CalendarExtender1" targetcontrolid="txtAdmissionDate"   runat="server" filtermode="ValidChars" filtertype="Custom" validchars="1234567890/">
  <asp:imagebutton runat="Server" id="imgDatepicker" imageurl="~/Calendar.png" />

Please do not forget to vote if could help...
sofia3 4-Jun-12 9:20am
if you will do read only textbox value will be empty on code behind it will not set no matter in frontend it will be displayed.
Hi there,
If you are using ajax calender extender then use this:

<asp:TextBox CssClass="controls" ID="txtPOITo" runat="server" Width="125px" ReadOnly="True" />
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/Images/Calendar_scheduleHS.png"/>
<cc1:CalendarExtender ID="CalendarExtender2" TargetControlID="txtPOITo" Animated="true"
PopupButtonID="ImageButton2" Format="dd/MM/yyyy" PopupPosition="BottomRight" runat="server">

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900