0

I need to disable the keyboard "Go" button when the following occur at the same time:

  1. Username textfield is empty AND
  2. Password textfield has focus (even if there is text already entered in the password field)

I have two text fields "txtUsername" and "txtPassword" with the following properties set:

[txtUsername setReturnKeyType:UIReturnKeyNext];
[txtPassword setReturnKeyType:UIReturnKeyGo];
[txtPassword setEnablesReturnKeyAutomatically:YES];

The "Go" button gets disabled only when the password text field is empty (doesn't matter if there is text in the username text field or not)... I'm not sure how to go about solving it when the above two conditions are met..

Connor Pearson
  • 63,902
  • 28
  • 145
  • 142

1 Answers1

2

Instead of trying to disable the "Go" button (which is user unfriendly), why not have a "next" button instead (which would imply the user goes to the next text field to enter in required text there)?

For this, you'd do:

[txtUsername setReturnKeyType:UIReturnKeyNext];

until all the fields you want have all the text you need to do (e.g. in the password field like you were mentioning):

[txtPassword setReturnKeyType:UIReturnKeyGo];
[txtPassword setEnablesReturnKeyAutomatically:YES];
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • I didn't really think of that as a solution but I could use it. However I'm still interested to find out if it's possible to keep the "Go" button and disable it! Thanks! – chillyb Feb 20 '14 at 05:30
  • [Here's a related question](http://stackoverflow.com/questions/788323/disable-enable-return-key-in-uitextfield) on how to truly disable the return (or "Go") key, but I still think what you're trying to do is user unfriendly. – Michael Dautermann Feb 20 '14 at 05:37