Search code examples
iphonehtmlformskeyboard

Getting iPhone GO button to submit form


Is anyone aware of what variables go into a form to make the iPhones virtual keyboard's GO button submit the form vs. not?

I've been trying to narrow down the scenarios and this is what I've found:

  • if FORM has only one user input field, go button automatically submits form

  • if FORM has more than one user input field, but no INPUT TYPE="SUBMIT" then the GO button does not submit the form.

  • if FORM has more than one user input field AND has an INPUT TYPE="SUBMIT" then the go button does submit the form.

However, that's not completely accurate, as we're running into a situation the 3rd isn't working for us.

Is anyone aware of the other factors that go into the GO button working vs. not working?


Solution

  • So, here was our specific issue:

    We had a form with multiple user input fields, but not a true <input type="submit"> (it was being submitted via JS).

    As such, the GO button did nothing.

    We then added an <input type="submit"> and set it to display: none hoping that would do the trick. Nope. Didn't work.

    On a whim, we changed display: none to margin-left: -1000px

    That worked!

    Apparently, Safari is looking for the presence of a SUBMIT button in the form and only if it's not display: none, it will then fire it when you hit the GO button.