html PhoneGap Android:数字软键盘有下一个而不是转到按钮
这让我发疯,我在任何地方都找不到答案。
我的phonegap 应用程序中有表格。如果输入type=“text”,则弹出文本键盘,并在角落显示“go”。当您单击“开始”时,它会提交表单。这一切都按我的预期进行。但如果我使用输入类型=“数字”,则会弹出数字键盘,并在角落中显示“下一个”。当您单击“下一步”时,如果按钮标签之前还有另一个输入框,则会转到该输入。没关系。 。 。不理想,但有道理。但如果它是页面上的最后一个输入字段,则单击“下一步”不会执行任何操作。它不会将焦点放在按钮上(即使使用 tabindex),也不会提交表单(理想情况)。
我正在使用phonegap 1.3.0 和jquery 1.7(如果有帮助的话)。
This is driving me crazy and I can't find the answer anywhere.
I have forms in my phonegap app. If the input type="text", the text keyboard pops up and "go" is displayed in the corner. When you click go, it submits the form. That all works as I would expect. But if I use input type="number", the number keyboard pops up and "next" is displayed in the corner. When you click next, if there is another input box before the button tag, it goes to that input. That's okay. . . not ideal, but makes sense. But if it is the last input field on the page, click "next" does nothing. It doesn't put focus on the button (even with tabindex) and it doesn't submit the form (ideal).
I'm using phonegap 1.3.0 and jquery 1.7 if any of that helps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过在 JQuery 中使用以下绑定来检测下一次键盘按下:
“下一个”按钮模拟键盘上的 Tab 键按下事件,即键代码 9。不幸的是,keypress 和 keyup 事件不会检测下一个键事件,因此你需要将它绑定在 keydown 上。
希望有帮助!
You can detect the next keyboard press by using the following bind in JQuery:
The 'next' button emulates the tab keypress event on a keyboard, which is key code 9. Unfortunately, keypress and keyup events do not detect the next key event, so you need to bind it on keydown.
Hope that helps!
好吧,现在我确实有了一些看起来像答案并且嘎嘎叫起来像答案的东西。
这是一次可怕的黑客攻击,目前我正在经历一些副作用,但无论如何这对人类来说是一个小小的飞跃。
将不可见的文本输入添加到表单中,一旦获得焦点就会自动提交表单。由于它只能从用户按“下一步”或从最后一个数字字段按 Tab 键接收焦点,因此用户序列中应该有相当可靠的逻辑。
副作用是:
使用 onfocus 处理程序也可以重新关注数字字段
刚刚离开。或者您可以将输入的宽度设置为 0。后者最适合我。
Okay, now I do have something that looks like an answer and quacks like an answer.
It's a horrible hack, and I am experiencing some side-effects at this point, but it's a small leap for mankind anyway.
Add an invisible text input to your form, which automatically submits the form as soon as it receives focus. Since it can only receive focus from the user pressing 'Next' or tabbing from the last number field, there should be a pretty solid logic in the user sequence.
The side effects are:
using the onfocus handler to also re-focus on the number field that
was just left. Or you can set the width of the input to 0. The latter works best for me.