disabling the ENTER button to trigger a button?

P

paul814

Hello,
I've got an online form, with textboxes and drop downs and at the end
a SUBMIT button.

My users are used to hitting ENTER to move from field to field, and
right now if they hit ENTER, the button is executed, or the .php page
post action is executed.

Is there a way to disable this so the only way the post action will
occur is if the button is clicked? how?

thanks.
 
J

Jukka K. Korpela

Scripsit (e-mail address removed):
My users are used to hitting ENTER to move from field to field,

They have to learn to abandon such habits when filling out forms on the
web, since in most situations, Enter submits the form.

Do you want to slow down their learning process?
and
right now if they hit ENTER, the button is executed, or the .php page
post action is executed.
Right.

Is there a way to disable this so the only way the post action will
occur is if the button is clicked? how?

Not really, and you don't want that. What would those people do who have
no mouse to click with or have some disability that prevents them using
the mouse "normally"?

But taking "clicking" abstractly enough, it's a reasonable goal, but
it's possible to a limited extent only.

This used to be a FAQ, in the old days when FAQs flourished, the climate
was mild and pleasant, people acted reasonably etc. You could still dig
up some dusty old FAQ and follow some links and finally find this:
http://www.cs.tut.fi/~jkorpela/forms/enter.html
which explains:

Include the following element into the head part of your document:

<script type="text/javascript">
function noenter() {
return !(window.event && window.event.keyCode == 13); }
</script>

Add the following attribute into each input type="text" tag(s) in your
form:
onkeypress="return noenter()"

It might just work, part of the time.
 
J

Jonathan N. Little

Jukka said:
Scripsit (e-mail address removed):
Include the following element into the head part of your document:

<script type="text/javascript">
function noenter() {
return !(window.event && window.event.keyCode == 13); }
</script>

Add the following attribute into each input type="text" tag(s) in your
form:
onkeypress="return noenter()"

It might just work, part of the time.

As Jukka says, any JavaScript solution will only work *some* of the
time. In the end what you need to do is have your receiving script check
for missing required fields, and if empty, return to the fill in form
with error message about the missing fields.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top