2

I have a form which I want the user to fill in and I want to have the keypad to pop up on the iphone automatically when they hit that page instead of them tapping on the input box first. What is the special tag in order to achieve that?

Also, is it possible to set a timer, eg: 3 seconds, then have the keypad pop up, instead of popping up immediately.

Thanks in advance.

Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131
Linda
  • 33
  • 3

2 Answers2

2

In your -(void)viewDidAppear:(BOOL)animated calling [theTextField becomeFirstResponder]; will make the keyboard appear for you (where theTextField is the first textField on the form.

If you set up a method as follows:

-(void) setFocusToTextbox {
[theTextField becomeFirstResponder];

}

and in -(void)viewDidAppear:(BOOL)animated have:

[NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(setFocusToTextbox) userInfo:nil repeats:NO]; 

The keyboard should appear 3.0 seconds after the view does.

davbryn
  • 7,156
  • 2
  • 24
  • 47
  • Sorry, I should have made it clear that it is not an Objective C app, it is simply an JSP web page. Any solutions in java, html, css, or javascript? thanks. – Linda Jul 19 '10 at 13:49
1

There's no tag, but there is JavaScript to do it. After your page has loaded, you need to call focus() on the textfield you want the keyboard to show for.

Matt Moriarity
  • 697
  • 5
  • 13
  • Unfortunately that still doesn't pop open the keyboard, it just sets focus to teh element (highlight) but the cursor is not there waiting for user input and the keyboard remains closed. Note that it is different on a desktop browser, where .focus *does* leave the cursor in a state of entry. – Allbite Jun 18 '12 at 21:56