Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
how to validate calendar extender on a textbox...it has to take only date i have use filtered control and gave valid char as no's only...it 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
Posted

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:-

http://forums.asp.net/t/1117573.aspx[^]

http://forums.asp.net/t/1033596.aspx[^]

http://stackoverflow.com/questions/3005425/how-to-check-or-validate-the-textbox-entered-date-is-in-dd-mm-yyyy-format[^]

I hope this will help you out.

Thanks
 
Share this answer
 
Comments
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
 
Share this answer
 
Comments
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..
Hi,

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" %>

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


Please do not forget to vote if could help...
 
Share this answer
 
v3
Comments
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:

XML
<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">
</cc1:CalendarExtender>
 
Share this answer
 

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