用 Phonegap 中的 Next 替换软键盘上的 Go 按钮 [英] Replace Go button on soft keyboard with Next in Phonegap

查看:25
本文介绍了用 Phonegap 中的 Next 替换软键盘上的 Go 按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Phonegap 输入类型文本在软键盘上显示 Go 按钮,我有多个文本框,所以想要键盘上的 Next 按钮,以便用户可以轻松移动,最后输入想要 Go,因此用户可以按下提交表单.

Phonegap input type text show Go button on soft keyboard, I have multiple text boxes so want Next button on keyboard so user can move easily and on last input want Go so user can press to submit form.

并且在 Android kitkatt 键盘顶部栏也不显示 Next|Prev 按钮.

And on Android kitkatt keyboard top bar also not displaying Next|Prev buttons.

推荐答案

到目前为止,Android 无法为 input type="text" 使用下一步"按钮而不是开始"按钮.

Having a "Next" button instead of "Go" for input type="text" would not be possible with Android as of now.

Android 将始终为表单输入字段显示Go"按钮,而不管您在表单中的字段位置如何.Go"基本上反映了与普通浏览器上的Enter"按钮相同的行为键盘.

Android will always display "Go" button for form input fields irrespective of the position of the field you are at in the form. "Go" is basically reflecting the same behavior as of an "Enter" button on a normal browser & keyboard.

有两种可能的技巧可以更接近您的需要(仍然不会将Go"更改为Next",但会帮助Go"充当Next")-

There are two possible hacks to come closer to what you need (still won't change "Go" to "Next" but will help "Go" act as "Next") -

Hack 1 - 劫持 Enter 键事件 &将焦点移到下一个字段

就像我提到的Go"键复制Enter"键一样,您可以使用 JavaScript & 捕获 Enter 键事件.让它将焦点移到表单中的下一个字段,直到它的最后一个字段.一旦到达最后一个字段,您就可以让它充当输入.所以基本上 Go 会继续将焦点转移到下一个领域,直到它成为你的最后一个领域 &然后将提交表单.

Like I mentioned the "Go" key replicates the "Enter" key, you can capture the enter key event using JavaScript & make it move focus to next fields in form until its your last field. Once last field reaches you can allow it to act as enter. So basically Go will keep moving focus to next fields until its your last field & then will submit the form.

我在这里回答了类似要求的解决方案 - 如何在用户按下 Enter 时触发 Tab ,您可以尝试在您的应用中实现相同的功能.

I have answered a solution to a similar requirement here - How to trigger a Tab when user presses Enter, you can try implementing the same in your app.

演示链接 - http://codepen.io/nitishdhar/pen/Gxbhm

Hack 2 - 强制表单验证 &将焦点移到下一个无效字段

如果您想阻止用户提交表单,您可以使用 java-script & 将所需的验证放在表单上.如果某些字段未填充,则在按Go"后,光标的焦点可以移至下一个未填充"字段.所以在某种程度上给人的印象是 - 按 Go & 移动到下一个要填写的字段"

If you want to prevent users from submitting the form, you can put required validations on the form using java-script & if some field is not filled, upon pressing "Go" the focus of the cursor can be brought to the next "not filled" field. So in a way giving the impression of - "Pressing Go & moving to next field to be filled"

试试这个插件 - http://jqueryvalidation.org/ 这就像解释的那样,将焦点移到下一个必填或无效字段.

Try this plugin - http://jqueryvalidation.org/ this behaves in the way explained i.e moves focus to the next required or invalid field.

此外,我认为某些 android 版本会在键盘上显示一些 Tab 键以在字段之间移动,但不是 Next.

Also I think some android versions show some tab key on the keyboard to move between fields, buts its not Next.

一切顺利.

这篇关于用 Phonegap 中的 Next 替换软键盘上的 Go 按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆