Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

input type=date in iOS 7

I have developed a mobile web application and I noticed a change concerning iOS 7, specifically:

  • If a web page form contains an input tag of type=date, and the value of the date field is empty (no date value), then the field is rendered in a strange way in Safari, so that the height of the text box is very small (approximately 25% of the height of a normal input type=text box). Once a date is entered into the control, then the height of the text box is the same as a type=text box.

This did not happen in iOS 6 but is happening in iOS 7. The problem is that it does not look good to me to see these date input boxes rendered in this way. I would prefer that they look the same as a normal type=text box even when empty.

  • Is there anything I can do to get that to happen?
  • Is there some initial value I can pass to the type=date text boxes to make them render as they always have?

Thanks in advance.

updated with screenshots:

good: enter image description here

bad: enter image description here

(that white box should be taller and showing placeholder text)

like image 660
Obi Wan Avatar asked Sep 23 '13 20:09

Obi Wan


People also ask

Is type date supported in Safari?

Safari does not support the HTML5 date and time input types: https://caniuse.com/#feat=input-datetime.

How do I get the input type for a date?

<input type="date"> <input> elements of type="date" create input fields that let the user enter a date, either with a textbox that validates the input or a special date picker interface. The resulting value includes the year, month, and day, but not the time.

How do you change the input type date in dd mm yyyy format?

To set and get the input type date in dd-mm-yyyy format we will use <input> type attribute. The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from.

Is input type date accessible?

The ones that claim to be accessible aren't. For example, we know <input type="date"> is a problem for voice users across browsers. Graham Armfield already produced a thorough report on the accessibility of the native control and came to conclusion that nope, it is not accessible.


1 Answers

As suggested above, the solution is to manually set the height of the input type=date html control. A height of 20px for me makes it appear to be the same as the other controls on the page and it looks good.

like image 83
Obi Wan Avatar answered Dec 09 '22 19:12

Obi Wan