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
472 views
in Technique[技术] by (71.8m points)

android - Replace Go button on soft keyboard with Next in Phonegap

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.

enter image description here

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

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

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

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.

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 - Hijack Enter key event & move focus to next fields

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.

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.

DEMO LINK - http://codepen.io/nitishdhar/pen/Gxbhm

Hack 2 - Force form validation & move focus to next invalid fields

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"

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

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

All the best.


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

...