0

Submit form when enter pressed in field

asked 2012-05-09 16:25:45 +0800

iwagner gravatar image iwagner
45

I have a form with some text boxes and then a submit button. I want the form to be submitted when the user presses enter after typing in some information -- e.g. the textbox is in focus, not the submit button. How can I do this?

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2012-05-09 16:53:55 +0800

satan87 gravatar image satan87
255

i'm using something like that
pwd is the name of the textbox
btnlog is the name of the submit button

....
private Textbox pwd;
private Button btnlog;
...


public void onClick$btnlog()
	{
		loginCheck ();
	}

	public void onOK$pwd()
	{
		loginCheck () ;
	}
	
	
	private void loginCheck () 
    {
		if ( ei.getLogin(name.getValue(), pwd.getValue()) ) 
        {
    		....
}
		
    }

link publish delete flag offensive edit

answered 2012-05-09 19:10:06 +0800

iwagner gravatar image iwagner
45

Thank you! Binding to the onOK event of the textbox worked.

link publish delete flag offensive edit

answered 2012-05-09 19:27:45 +0800

Matze2 gravatar image Matze2
773 7

As far as I know, you can do that also in ZUL directly. Untested:

<textbox ... forward="onOK=btnSubmit.onClick"/>

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-05-09 16:25:45 +0800

Seen: 241 times

Last updated: May 09 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More