Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Blocking form submission with enter

LEGEND ,
Jan 10, 2008 Jan 10, 2008

Copy link to clipboard

Copied

Is there a really good way to prevent this from happening?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


TOPICS
Server side applications

Views

347
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 10, 2008 Jan 10, 2008

Copy link to clipboard

Copied

OK - I found this -

A quick search at http://www.irt.org/ returned the results:

>From their FAQ's
<script language="JavaScript"><!--
var buttonPressed = false;
//--></script>

<form onSubmit="return buttonPressed">
...
<input type="Submit" onClick="buttonPressed = true">
</form>"

or


http://developer.irt.org/script/2066.htm
"This can be achieved by submitting the form using the onClick event handler
instead of onSubmit event handler. It is necessary to return false on event
handler onSubmit to prevent submit on hitting ENTER key. Sample code:

<.form name="form1" onSubmit="return false">
<.input type="text">
<.input type="button" value="SubmitForm" onClick="document.form1.submit()">
<.a href="#" onClick="document.form1.submit()"><img src="button.gif"></a>
<./form>"

or even

"Yes - The following code will block the enter key in all browsers 4.0
above, except when enter is pressed in a Textarea or on the Submit button
itself."
http://developer.irt.org/script/1693.htm


I'm trying it now....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:fm6679$qvq$1@forums.macromedia.com...
> Is there a really good way to prevent this from happening?
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> ==================
>
>

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 11, 2008 Jan 11, 2008

Copy link to clipboard

Copied

.oO(Murray *ACE*)

>Is there a really good way to prevent this from happening?

Only with JavaScript, but that's not really good. Why do you need that?

Micha

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 11, 2008 Jan 11, 2008

Copy link to clipboard

Copied

I'm OK with using js to block it. I'm in a shopping cart, and there are
some fields that are optional, but that do need to be filled in properly if
used. One mistake and the form submits, which I don't want to happen.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Michael Fesser" <netizen@gmx.de> wrote in message
news:iqaeo39le5tvp5nvi2u6q263koe5nvefv8@4ax.com...
> .oO(Murray *ACE*)
>
>>Is there a really good way to prevent this from happening?
>
> Only with JavaScript, but that's not really good. Why do you need that?
>
> Micha

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 11, 2008 Jan 11, 2008

Copy link to clipboard

Copied

.oO(Murray *ACE*)

>I'm OK with using js to block it. I'm in a shopping cart, and there are
>some fields that are optional, but that do need to be filled in properly if
>used. One mistake and the form submits, which I don't want to happen.

Remember that JS can be turned off or configured to not capture input
events, which will make possible to submit incomplete or invalid form
data. And since all the form values have to be validated on the server
anyway, I don't see much reason to block a useful and convenient browser
function. YMMV.

In my forms the users can enter whatever they want. If some values are
incomplete or invalid and not acceptable to the processing script, the
form is simply shown again with some error messages, that's it. And for
convenience I could also add some JS-based pre-validation if I want, so
pressing [enter] on an incomplete field would trigger an immediate error
message without another roundtrip to the server. All these things are so
common and used on most forms in the WWW.

But who am I telling that, you should already know all that. ;)

Micha

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 11, 2008 Jan 11, 2008

Copy link to clipboard

Copied

LATEST
> But who am I telling that, you should already know all that. ;)

Of course. Wouldn't have asked if I didn't have a good reason for doing so!
8)

It's a complex form, deep in a shopping cart. I'm afraid of breaking
something in the midst of all that server scripting. Disabling the Enter
key on submit would be an easy way of solving the problem, and would avoid
the issue of someone only actually wanting to fill out 3 of the 5 input
fields, then challenging them to respond whether this is really what they
wanted, then figuring out how to allow the form to submit if the response is
yes, etc., etc.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Michael Fesser" <netizen@gmx.de> wrote in message
news:m6leo3tnpdmk1eo59tcm6hkrbd2o5kid1l@4ax.com...
> .oO(Murray *ACE*)
>
>>I'm OK with using js to block it. I'm in a shopping cart, and there are
>>some fields that are optional, but that do need to be filled in properly
>>if
>>used. One mistake and the form submits, which I don't want to happen.
>
> Remember that JS can be turned off or configured to not capture input
> events, which will make possible to submit incomplete or invalid form
> data. And since all the form values have to be validated on the server
> anyway, I don't see much reason to block a useful and convenient browser
> function. YMMV.
>
> In my forms the users can enter whatever they want. If some values are
> incomplete or invalid and not acceptable to the processing script, the
> form is simply shown again with some error messages, that's it. And for
> convenience I could also add some JS-based pre-validation if I want, so
> pressing [enter] on an incomplete field would trigger an immediate error
> message without another roundtrip to the server. All these things are so
> common and used on most forms in the WWW.
>
> But who am I telling that, you should already know all that. ;)
>
> Micha

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines