Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

In my web application i am using TextBox as Datepicker by JQuery.Whenever that Textbox gets focus a Calender is popig up and It`s working fine but the problem is while Textbox having focus if i enter numbers 0 to 9 and simble "/" Textbox is accepting this not other simbles and characters.

I want to restrict entering any type of data into that textbox including numbers 0 to 9 and simble "/" also.


Please anybody help me to achive this one.

Thanks in advance
Posted

set
XML
<asp:TextBox ID="txtDate" Width="245px" runat="server" CssClass="input2" onclick="Showcalander1(event)"></asp:TextBox>&nbsp<img
                                        src="images/icon_calander.gif" id="imgdate" runat="server" onclick="Showcalander1(event)"
                                        style="display: inline" />

and from code behing on page load set this

C#
txtDate.Attributes.Add("readonly", "readonly");
 
Share this answer
 
Comments
udaysimha 31-Oct-11 9:15am    
Hi Anuja

Thanks for your`s reply.Can you please explain me about onclick="Showcalander1(event)" and why you takes image tag here.

I tried this
txtDate.Attributes.Add("readonly", "readonly");
it`s not working

Please give me some explation to understand better.

Thanks
uday
Anuja Pawar Indore 31-Oct-11 9:24am    
Uday,
Showcalander1 is my javascript function to call the calendar control. user when click on text box or calendar image my JS calendar pop's up for date selection
Anuja Pawar Indore 31-Oct-11 9:28am    
I am using scw.js and my function is this
function Showcalander1(ev1) {
scwShow(scwID('<%=txtDate.ClientID %>'), ev1);
}
udaysimha 1-Nov-11 4:36am    
Hi Anuja,

Thanks for your reply,here i am using JQuery to pop`s up Calendar when user click on TextBox.After clicking on TextBox a calendar is poping up and if user press keys in keyboard from 0 to 9 and symbal "/" it(text box) accepting that. So i want to restrict user to enter any data rather i want to allow user to select date form calendar only.

If you have any idea please help me.

Thanks
uday
Hi,

You can try this[^].
 
Share this answer
 
Comments
udaysimha 31-Oct-11 8:21am    
Hi Anup Das Gupta

Thanks for your`s reply,Here my requirement is not to validate the date entered by the user .Here whenever user moves cursor into date filed Textbox it will pop the calendar, user should select date from calendar only and user should not allow to enter date manualy(means by pressing keys in keyboard).

Please help me to achive this.ThanksUday

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