Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

html - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...