Search code examples
iosios5uiwebviewcordovamobile-safari

iOS 5: Input placeholder doesn't clear on focus, only on input, bug or feature?


Playing around with my web application in the iOS 5 simulator, I noticed that iOS 5 doesn't clear placeholders immediately, only after the first input. On all other version of iOS as well as on all desktop browsers, the placeholder is immediately cleared when the user focuses on the input. I don't have access to an iOS 5 device right now but I highly doubt this is a simulator error.

Is this a bug or intended? Oddly I only found one reference to this behavior on the net, right here on SO: clearing input placeholder in iOS5

Is there a workaround for this problem? It's quite frustrating for the user when the placeholder doesn't clear immediately.


Solution

  • I think you are mistaken - iOS text fields always behave this way.

    I don't see why this would be frustrating for the user. If anything it is helpful that the helper text stays visible until they begin typing, in case they missed it before selecting the field.

    What may be confusing you is that iOS fields have a separate optional behaviour where the text is cleared when the field is selected, but note that this is the actual text that clears, not the placeholder text.

    Placeholder text is the light grey text, and this always appears until the user types something.

    Content text (usually black) sometimes clears when the field is focussed and sometimes doesn't, depending on how the UITextField was configured.

    The jQuery solution in the SO question you linked to should let you replicate any variant of this functionality that you desire, but personally I'd advise sticking with the iOS convention of not clearing helper text until the user types something.