For the life of me I cant figure out why you want to do this... any time you
change expected behavior you decrease usabilty and  thereby increase user
frustration.

Regardless, the following should work:
<script type="text/javascript">
function noenter() {
  return !(window.event && window.event.keyCode == 13); }
</script>

<input type='text' onkeypress="return noenter()" name='userid'>


On Tue, Aug 31, 2010 at 7:57 AM, jhaagmans <jaap.haagm...@gmail.com> wrote:

> The thing is, I don't want to stop the form from submitting all
> together, I want to stop it from submitting when hitting enter in the
> login part of the form.
>
>
> On 23 aug, 10:27, Johan Arensman <johanm...@gmail.com> wrote:
> > You could also try to observe the form and prevent it from submitting:
> >
> > YourFormElement.observe('submit', function submitEvent(event) {
> >   event.stop(); // stops the form from actually submitting
> >   // other code you would like to run
> >
> > });
> > On Mon, Aug 23, 2010 at 10:24 AM, jhaagmans <jaap.haagm...@gmail.com>
> wrote:
> > > I'm not sure what you mean. I want to submit the login part using
> > > enter, but I want it to use another action. I also want to submit the
> > > registration form using enter, so outside the password field I don't
> > > want to prevent the registration submit from executing.
> >
> > > Thanks.
> >
> > > On Aug 23, 2:51 am, Phil Petree <phil.pet...@gmail.com> wrote:
> > > > you would need to check an onClick= within the <input type=submit
> >
> > > > On Sun, Aug 22, 2010 at 7:37 PM, jhaagmans <jaap.haagm...@gmail.com>
> > > wrote:
> > > > > Using an onkeypress action on the password field. Thanks!
> >
> > > > > On Aug 23, 1:17 am, Phil Petree <phil.pet...@gmail.com> wrote:
> > > > > > how are you calling this from the form?
> >
> > > > >  > On Sat, Aug 21, 2010 at 4:56 AM, jhaagmans <
> jaap.haagm...@gmail.com
> >
> > > > > wrote:
> > > > > > > Hi,
> >
> > > > > > > I'm using a RedBox to display an AJAX registration/login form.
> The
> > > > > > > problem with RedBox is that you can't use two forms inside a
> > > RedBox.
> > > > > > > I'm not sure why that is, but it just doesn't work. My solution
> was
> > > to
> > > > > > > put both the login part and the registration part in one form
> and
> > > > > > > toggle both form-parts using a radio button. So far no
> problems: it
> > > > > > > works nicely. However, I really want both form parts to go to
> > > > > > > different actions, so I set the form action to the registration
> url
> > > > > > > and added a button in the (at first hidden) login part that
> submits
> > > > > > > the form to the login url. That also works nicely. When enter
> is
> > > > > > > pressed, however, it will submit to the registration URL. I
> thought
> > > > > > > I'd work around that using a keypress handler on the login
> > > textfields,
> > > > > > > which works, but after initiating the request to the login
> action,
> > > it
> > > > > > > will also send a request to the general form action.
> >
> > > > > > > The code I use for the onKeypress handler is this:
> >
> > > > > > > function check_login_keypress(myfield, e) {
> > > > > > >    var keycode;
> > > > > > >    if (window.event) keycode = window.event.keyCode;
> > > > > > >    else if (e) keycode = e.which;
> > > > > > >    else return true;
> >
> > > > > > >    if (keycode == 13)
> > > > > > >    {
> > > > > > >        new Ajax.Request('/user_sessions', {asynchronous:true,
> > > > > > > evalScripts:true, parameters:Form.serialize(myfield.form)});
> > > > > > >        return false;
> > > > > > >    }
> > > > > > >    else
> > > > > > >        return true;
> > > > > > > }
> >
> > > > > > > What am I doing wrong?
> >
> > > > > > > Thank you in advance!
> >
> > > > > > > Kind regards,
> > > > > > > Jaap Haagmans
> >
> > > > > > > --
> > > > > > > You received this message because you are subscribed to the
> Google
> > > > > Groups
> > > > > > > "Prototype & script.aculo.us" group.
> > > > > > > To post to this group, send email to
> > > > > > > prototype-scriptacul...@googlegroups.com.
> > > > > > > To unsubscribe from this group, send email to
> > > > > > > prototype-scriptaculous+unsubscr...@googlegroups.com<prototype-scriptaculous%2bunsubscr...@googlegroups.com>
> <prototype-scriptaculous%2bunsubscr...@googlegroups.com<prototype-scriptaculous%252bunsubscr...@googlegroups.com>
> >
> > > <prototype-scriptaculous%2bunsubscr...@googlegroups.com<prototype-scriptaculous%252bunsubscr...@googlegroups.com>
> <prototype-scriptaculous%252bunsubscr...@googlegroups.com<prototype-scriptaculous%25252bunsubscr...@googlegroups.com>
> >
> > > ><prototype-scriptaculou
> > > > > s%2bunsubscr...@googlegroups.com<s%252bunsubscr...@googlegroups.com><
> s%252bunsubscr...@googlegroups.com <s%25252bunsubscr...@googlegroups.com>
> ><
> > > s%252bunsubscr...@googlegroups.com<s%25252bunsubscr...@googlegroups.com><
> s%25252bunsubscr...@googlegroups.com<s%2525252bunsubscr...@googlegroups.com>
> >
> >
> > > > > > > .
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/prototype-scriptaculous?hl=en.
> >
> > > > > --
> > > > >  You received this message because you are subscribed to the Google
> > > Groups
> > > > > "Prototype & script.aculo.us" group.
> > > > > To post to this group, send email to
> > > > > prototype-scriptacul...@googlegroups.com.
> > > > > To unsubscribe from this group, send email to
> > > > > prototype-scriptaculous+unsubscr...@googlegroups.com<prototype-scriptaculous%2bunsubscr...@googlegroups.com>
> <prototype-scriptaculous%2bunsubscr...@googlegroups.com<prototype-scriptaculous%252bunsubscr...@googlegroups.com>
> >
> > > <prototype-scriptaculous%2bunsubscr...@googlegroups.com<prototype-scriptaculous%252bunsubscr...@googlegroups.com>
> <prototype-scriptaculous%252bunsubscr...@googlegroups.com<prototype-scriptaculous%25252bunsubscr...@googlegroups.com>
> >
> >
> > > > > .
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/prototype-scriptaculous?hl=en.
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Prototype & script.aculo.us" group.
> > > To post to this group, send email to
> > > prototype-scriptacul...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > prototype-scriptaculous+unsubscr...@googlegroups.com<prototype-scriptaculous%2bunsubscr...@googlegroups.com>
> <prototype-scriptaculous%2bunsubscr...@googlegroups.com<prototype-scriptaculous%252bunsubscr...@googlegroups.com>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/prototype-scriptaculous?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> prototype-scriptacul...@googlegroups.com.
> To unsubscribe from this group, send email to
> prototype-scriptaculous+unsubscr...@googlegroups.com<prototype-scriptaculous%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to