I have a form with an date field with a jquery datepicker attached to it.
When I select the date field the datepicker pops up but then the iPad keyboard slides into
Three hours in now and getting nowhere. I don't have an Iphone so i'm trying the above on an android phone running 2.3.
On my phone I still get the keypad everytime, nothing stops it and I can't use 'read only' as it stops my asp.net4 / C# code behind firing, which is a bit cr#p but that's how it is.
So my initial question is do these ideas only work on Iphones?
cheers
I've found a way to make the above answers work for ASP.Net 4. so thought I would share.
Seems that < asp:TextBox ID="something" ...> doesn't fire Javascript or JQuery as it's assigned a 'special' ID like "ctl00_content....." on the server side, which isn't the same as "#something" in the JQuery code. But thanks to trial and error using this posting:-
Retrieve value from asp:textbox with JQuery
I worked out that using the following (with thanks to above poster) will blur the focus and stop mobile phones showing the keyboard (atleast my Android anyway :)
$("#<%=sDatepicker.ClientID%>").focus(function () {
$(this).blur();
});
so the following simple example code used with the JQuery above should hopefully help others:
Of course 'sDatepicker_changed' is your code behind code.
protected void sDatepicker_changed(object sender, EventArgs e)
{//do stuff here..}
I can also run the datepicker pop up still and use my code behind function to populate another textbox with an end date 7 days from this one.
It would seem this only works in mobile phones! in a browser it throws an "Object reference not set to an instance of an object" because asp.net has decided the TextBox doesn't exist after a postback but runs JavaScript. Getting off topic so won't say anymore.
All sorted now :) , have surrounded my and cheers Trev. with a
JavaScript
code, when I have detected it is a mobile device, by using:
bool IsMobile = Page.Request.Browser.IsMobileDevice;
if (IsMobile == true)
{
mobileScript.Visible = true;
}