I'm currently developing a website aimed at iPhones/ iPads.
Setting the input type to date changes the field appearance to a drop down menu, and the placeholder attribute that works with text fields only shows on the desktop version, not on the iphone. Is there a way around this?
I want to get rid of that closing date text and have something similar to the dropdown menu above it.
Its basically just so that I can let the user know what they are entering without the need to use any extra space on the screen, so its not the biggest issue if there is no solution.
回答1:
Took me a while figuring this one out, leave it as type="text", and add onfocus="(this.type='date')"
I've made it work with some ":before" pseudo-class and a small bit of javascript. You will have to have a class or id on your input. Here is a sample with an id of "myInput"
#myInput:before{ content:"Date of birth"; width:100%; color:#AAA; } #myInput:focus:before,#myInput.not_empty:before{ content:none }
Then in javascript, add the "not_empty" class depending on the value in the onChange and onKeyUp events.
You can even add all of this dynamically on every date fields.