Submit on Enter

75 views
Skip to first unread message

Neerav Verma

unread,
Jan 13, 2010, 10:09:42 AM1/13/10
to Zen Group
I have this login page. It works fine besides that after the user enters the credentials and presses enter it doesn't do anything
It requires for user to click on the button to go forward or tab and then enter

How can I make it work on Enter after keying password

XData Contents [ XMLNamespace = "http://www.intersystems.com/zen]
{
<page xmlns="http://www.intersystems.com/zentitle="CHC Login" >
<!--<titlePane title="Connected Health Care" />-->
<spacer height="25" />
<label value="Connected Health Care" align="center" />
<spacer height="25"/>
<form align="center" id="loginForm" nextPage="/csp/plato/CHE.csp" autoValidate="true" labelPosition="top">
    <text name="CacheUserName" label="Username:"  required="true"/>
    <spacer height="10"/>
    <password name="CachePassword" label="Password:"  required="true"/>
    <spacer height="10"/>
    <hgroup>
    <submit caption="Login" />
    <spacer width="10"/>
    <button caption="Clear" onclick="zen('loginForm').reset()"/>
    </hgroup>
  </form>
</page>
}

Thank You,

Neerav Verma
http://www.linkedin.com/in/vneerav
------------------------------------------------------
Pablo Picasso  - "Computers are useless. They can only give you answers."

Bill McCormick

unread,
Jan 13, 2010, 10:19:41 AM1/13/10
to intersys...@googlegroups.com
You have to add a little JS to the page that evaluates the onkeypressdown event, determines it is the enter key and then calls form.submit()


<ATT00001..txt>

Neerav Verma

unread,
Jan 13, 2010, 10:20:30 AM1/13/10
to intersys...@googlegroups.com
Do you by any chance have a code snippet?

Thank You,

Neerav Verma
http://www.linkedin.com/in/vneerav
------------------------------------------------------
Joan Crawford  - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend."

--
You received this message because you are subscribed to the Google Groups "InterSystems: Zen Community" group.
To post to this group, send email to InterSys...@googlegroups.com
To unsubscribe from this group, send email to InterSystems-Z...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/InterSystems-ZEN?hl=en
Zen Community Terms and Conditions: http://groups.google.com/group/InterSystems-ZEN/web/community-terms-and-conditions

Roberto

unread,
Jan 13, 2010, 10:48:19 AM1/13/10
to InterSystems: Zen Community
Do something on the keypress or keyup event etc. like this if it is an
enter key:

zenPage.getComponentById('ClientForm').submit()

-Roberto


On Jan 13, 10:20 am, Neerav Verma <vnee...@gmail.com> wrote:
> Do you by any chance have a code snippet?
>
> Thank You,
>
> Neerav Vermahttp://www.linkedin.com/in/vneerav
> ------------------------------------------------------

> Joan Crawford<http://www.brainyquote.com/quotes/authors/j/joan_crawford.html>

> > Pablo Picasso<http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html> - "Computers are useless. They can only give you answers."


> > <ATT00001..txt>
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "InterSystems: Zen Community" group.
> > To post to this group, send email to InterSys...@googlegroups.com
> > To unsubscribe from this group, send email to
> > InterSystems-Z...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/InterSystems-ZEN?hl=en
> > Zen Community Terms and Conditions:

> >http://groups.google.com/group/InterSystems-ZEN/web/community-terms-a...- Hide quoted text -
>
> - Show quoted text -

Markus Mechnich

unread,
Jan 13, 2010, 10:57:55 AM1/13/10
to intersys...@googlegroups.com
In a project we used the following solution:

....
  <password name="CachePassword" id="CachePassword" label="Passwort" onkeypress="zenPage.submitOnEnter()"/>
....
....
Method submitOnEnter() [ Language = javascript ]
{
    var form zenPage.getComponentById('loginForm');
    if (zenEvent.keyCode == zenENTER) {
        form.submit();
    }
}
....

HTH
Markus


Neerav Verma schrieb:

Neerav Verma

unread,
Jan 13, 2010, 11:09:30 AM1/13/10
to intersys...@googlegroups.com
Hey Markus.

Ok that worked.

Did you realize that label on your password has wrong spelling ;)

Only thing now is that if password is stored on the page, pressing enter doesn't do anything. 
not sure where to call that event from



Thank You,

Neerav Verma
http://www.linkedin.com/in/vneerav
------------------------------------------------------
Charles de Gaulle  - "The better I get to know men, the more I find myself loving dogs."

Markus Mechnich

unread,
Jan 13, 2010, 1:16:47 PM1/13/10
to intersys...@googlegroups.com
Hello Neerav,

maybe you're looking for the page's master keyeventhandler....

.....
/// This client event, if present, is fired when a keydown event occurs on the page.
Method onkeydownHandler(evt) [ Language = javascript ]
{
    if (zen("CachePassword").getProperty('value')!='') {
     if (evt.keyCode == zenENTER) {
         zen('loginForm').submit();
     }
    };
}


HTH
Markus

PS: FWIW "Passwort" was no typo it's just the german spelling ;-)

Neerav Verma schrieb:
Hey Markus.

Ok that worked.

Did you realize that label on your password has wrong spelling ;)

Only thing now is that if password is stored on the page, pressing enter doesn't do anything. 
not sure where to call that event from



Thank You,

Neerav Verma
http://www.linkedin.com/in/vneerav
------------------------------------------------------
Charles de Gaulle  - "The better I get to know men, the more I find myself loving dogs."

On Wed, Jan 13, 2010 at 10:57 AM, Markus Mechnich <Markus....@intersystems.com> wrote:
In a project we used the following solution:

.....

  <password name="CachePassword" id="CachePassword" label="Passwort" onkeypress="zenPage.submitOnEnter()"/>
.....
.....

Neerav Verma

unread,
Jan 13, 2010, 1:23:53 PM1/13/10
to intersys...@googlegroups.com
Ahh. Gotcha (About Passwort)

And it works beautifully now

Thanks a lot,


Neerav Verma
http://www.linkedin.com/in/vneerav
------------------------------------------------------
Joan Crawford  - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend."
Reply all
Reply to author
Forward
0 new messages