Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 440
Naseer Panhwer Avatar asked May 05 '14 10:05

Naseer Panhwer


1 Answers

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.

like image 90
Nitish Dhar Avatar answered Oct 12 '22 13:10

Nitish Dhar