views:

459

answers:

3

I can't get my iPhone to remember my username and password for the login to my website. The controls I currently have are:

<input type="text" name="username" id="username" />
<input type="password" name="password" id="password" />
<select>
    <option value="1">option1</option>
    <option value="2">option2</option>
</select
<input type="checkbox" name="rememberMe" id="rememberMe" />
<input type="button" value="Login" />

When the select is removed, it all works magically. Is there a way to declare / give safari extra hints that this is a logon page?

A: 

I'm not sure if that's your actual HTML or what that is, but if that's the html I can see why it wouldn't work. First thing you probably want to add are closing tags.

<input type="text"></input>
<input type="password"></input>
<select></select>
<input type="checkbox"></input>
<input type="button"></input>
KyleGobel
I updated the HTML to be more correct/complete, I was in a bit of a hurry when creating the question, sorry about that. The idea is that when the dropdown/select is added, the iPhone stops offering to save credentials, because it probably thinks it's no longer a login form, but a regular form.
Sander Rijken
Depending on the DTD, the closing </input> might not be necessary for it to be valid code. In XHTML, <input ... /> is valid.I don't know if the iPhone's autofill cares one way or the other. But in terms of valid code, inputs don't need closing tage.
charliepark
+3  A: 

I've tested with my iPhone and some test page with the following content makes the iPhone ask whether it should save the password and remember it the next time I visit the page.

x.html

<form action="x.html" method="POST">
  <input type="text" name="username" id="username" />
  <input type="password" name="password" id="password" />
  <select>
    <option value="1">option1</option>
    <option value="2">option2</option>
  </select>
  <input type="checkbox" name="rememberMe" id="rememberMe" />
  <input type="submit" value="Login" />
</form>

So basically it's the same as yours except that the button is of type "submit" instead of "button" and that there are form tags around the whole code snippet.

Etan
Thanks, I'll set up a test page, and see what happens, I'll keep you posted. Weird that it works though
Sander Rijken
A: 

Another thing you can try is to to add an ID and/or a name to the <select> tag.

Kai Chan