Don't submit form on Enter button

M

MichaelK

Who knows how to prevent submitting a form on the press Enter button before
all fields on the form are filled up.
People just enter the first field hit Enter and it submits the form and
doing validation,
of course flushing with the bunch of messages because rest of the fields are
empty.
I remember I had some pages where wrote the code to go on the next field
when pressed the Enter button (Tab like), because it didn't go anywhere at
all.
Tested it on a few machines, same result.

Thanks,
Michael
 
A

Anthony Jones

MichaelK said:
Who knows how to prevent submitting a form on the press Enter button before
all fields on the form are filled up.
People just enter the first field hit Enter and it submits the form and
doing validation,
of course flushing with the bunch of messages because rest of the fields are
empty.
I remember I had some pages where wrote the code to go on the next field
when pressed the Enter button (Tab like), because it didn't go anywhere at
all.
Tested it on a few machines, same result.

Tab is the standard 'next field' button. Do not use enter for this
operation. To avoid submit on enter add code to the onclick event of the
the submit button. Return false if not all fields are filled in.
 
D

Dave Anderson

[Please don't toppost on USENET]
It's still going to fire up submit on every Enter and run the code.

That is directly contradicted by what Anthony wrote. Returning [false]
cancels the event.
 
B

Bob Barrows [MVP]

Dave said:
[Please don't toppost on USENET]
It's still going to fire up submit on every Enter and run the code.

That is directly contradicted by what Anthony wrote. Returning [false]
cancels the event.

I think he was objecting to the fact that the code to check the field values
and cancel the event would run every time the Enter key was pressed, to
which my reply would be: so what? Whatever you do to change the meaning of
the Enter keypress will need to run every time the Enter key is pressed. An
alternative is to use the document's onkeypress event to change the keycode
from 13 (Enter) to 9 (tab). Post to a client-side scripting group such as
microsoft.public.scripting.jscript if you need help with this.
 
A

Anthony Jones

Bob Barrows said:
Dave said:
[Please don't toppost on USENET]
...To avoid submit on enter add code to the onclick event of the
the submit button. Return false if not all fields are filled in.

It's still going to fire up submit on every Enter and run the code.

That is directly contradicted by what Anthony wrote. Returning [false]
cancels the event.

I think he was objecting to the fact that the code to check the field values
and cancel the event would run every time the Enter key was pressed, to
which my reply would be: so what? Whatever you do to change the meaning of
the Enter keypress will need to run every time the Enter key is pressed. An
alternative is to use the document's onkeypress event to change the keycode
from 13 (Enter) to 9 (tab). Post to a client-side scripting group such as
microsoft.public.scripting.jscript if you need help with this.

The enter key simply initiates the default button. In a HTML form that is
the submit button.
By making making the submit input into an ordinary button there is no
default button Hence enter does not submit the form.

I was also steering the OP away from changing the behaviour of the Enter
button. The standard field navigation button is the tab button.
 
M

MichaelK

Thanks guys for responds.
I already figured it out.
Just had to change the type from "submit" to "button". Had this problem long
long time ago, just forgot how I solved it that time.
Seems it's what Anthony was metioned.

About standard Tab - I know that, just the forms were written for our
internal data entry people,
and it's a pretty difficult task to make them to don't press Enter every
time and use Tab instead.
So it was easier to capture Enter key and send them to the next entry field.

Happy coding guys.
Michael

Anthony Jones said:
Bob Barrows said:
Dave said:
[Please don't toppost on USENET]

MichaelK wrote:
...To avoid submit on enter add code to the onclick event of the
the submit button. Return false if not all fields are filled in.

It's still going to fire up submit on every Enter and run the code.

That is directly contradicted by what Anthony wrote. Returning [false]
cancels the event.

I think he was objecting to the fact that the code to check the field values
and cancel the event would run every time the Enter key was pressed, to
which my reply would be: so what? Whatever you do to change the meaning
of
the Enter keypress will need to run every time the Enter key is pressed. An
alternative is to use the document's onkeypress event to change the keycode
from 13 (Enter) to 9 (tab). Post to a client-side scripting group such as
microsoft.public.scripting.jscript if you need help with this.

The enter key simply initiates the default button. In a HTML form that is
the submit button.
By making making the submit input into an ordinary button there is no
default button Hence enter does not submit the form.

I was also steering the OP away from changing the behaviour of the Enter
button. The standard field navigation button is the tab button.
 
A

Anthony Jones

MichaelK said:
Thanks guys for responds.
I already figured it out.
Just had to change the type from "submit" to "button". Had this problem long
long time ago, just forgot how I solved it that time.
Seems it's what Anthony was metioned.

About standard Tab - I know that, just the forms were written for our
internal data entry people,
and it's a pretty difficult task to make them to don't press Enter every
time and use Tab instead.
So it was easier to capture Enter key and send them to the next entry
field.

Makes you wonder what they were using before that taught them to use the
enter button. If you perpetuate that it may be fine for this application but
still continue to be a source of confusion for them the when using other
applications. A better approach would be a bit of training, they'll get
used it.
 
E

Evertjan.

Anthony Jones wrote on 12 jul 2007 in
microsoft.public.inetserver.asp.general:
Makes you wonder what they were using before that taught them to use
the enter button. If you perpetuate that it may be fine for this
application but still continue to be a source of confusion for them
the when using other applications. A better approach would be a bit
of training, they'll get used it.

Like [IE example]:

<input type='text'
onkeypress=
'if (event.keyCode==13){
alert("Get used to not to use <enter> here, stupid!");
alert("I expected that question. Why not use <tab>");
return false;
};'
?
 
A

Anthony Jones

Evertjan. said:
Anthony Jones wrote on 12 jul 2007 in
microsoft.public.inetserver.asp.general:
Makes you wonder what they were using before that taught them to use
the enter button. If you perpetuate that it may be fine for this
application but still continue to be a source of confusion for them
the when using other applications. A better approach would be a bit
of training, they'll get used it.

Like [IE example]:

<input type='text'
onkeypress=
'if (event.keyCode==13){
alert("Get used to not to use <enter> here, stupid!");
alert("I expected that question. Why not use <tab>");
return false;
};'
?


That would not be my prefered way to do it.

I would book a conference room with a projector and show them a number of
applications which demonstrate that the tab is the industry wide field
navigation button. Apologise prefusely to them for having them use an
application in the past that did not conform to this standard and could they
please use the tab button from now on.

Be sure not to make them feel stupid, the fault lies with the management not
them.
 
E

Evertjan.

Anthony Jones wrote on 12 jul 2007 in
microsoft.public.inetserver.asp.general:
Evertjan. said:
Anthony Jones wrote on 12 jul 2007 in
microsoft.public.inetserver.asp.general:
Makes you wonder what they were using before that taught them to
use the enter button. If you perpetuate that it may be fine for
this application but still continue to be a source of confusion for
them the when using other applications. A better approach would be
a bit of training, they'll get used it.

Like [IE example]:

<input type='text'
onkeypress=
'if (event.keyCode==13){
alert("Get used to not to use <enter> here, stupid!");
alert("I expected that question. Why not use <tab>");
return false;
};'
?

That would not be my prefered way to do it.

I would book a conference room with a projector and show them a number
of applications which demonstrate that the tab is the industry wide
field navigation button. Apologise prefusely to them for having them
use an application in the past that did not conform to this standard
and could they please use the tab button from now on.

Be sure not to make them feel stupid, the fault lies with the
management not them.

An expensive way to teach them and have them not feel stupid, Anthony.

Feeling stupid has nothing to do wich whose fault it is, but is a mighty
strong incentive for a steep learning curve.

Perhaps the word "stupid" should only appear after the third <enter>?

My way they would not see those two alerts any more in an hour,
and also target the ones that are on holyday, congress, ill, sick,
buzy elsewhere or just too sleepy during your "conference room with a
projector" happening to notice.

However, in a setting where money is no object, and absolute politeness
is, your idea might eventually work.
 
A

Anthony Jones

Evertjan. said:
Anthony Jones wrote on 12 jul 2007 in
microsoft.public.inetserver.asp.general:
Evertjan. said:
Anthony Jones wrote on 12 jul 2007 in
microsoft.public.inetserver.asp.general:

Makes you wonder what they were using before that taught them to
use the enter button. If you perpetuate that it may be fine for
this application but still continue to be a source of confusion for
them the when using other applications. A better approach would be
a bit of training, they'll get used it.


Like [IE example]:

<input type='text'
onkeypress=
'if (event.keyCode==13){
alert("Get used to not to use <enter> here, stupid!");
alert("I expected that question. Why not use <tab>");
return false;
};'


?

That would not be my prefered way to do it.

I would book a conference room with a projector and show them a number
of applications which demonstrate that the tab is the industry wide
field navigation button. Apologise prefusely to them for having them
use an application in the past that did not conform to this standard
and could they please use the tab button from now on.

Be sure not to make them feel stupid, the fault lies with the
management not them.

An expensive way to teach them and have them not feel stupid, Anthony.

Feeling stupid has nothing to do wich whose fault it is, but is a mighty
strong incentive for a steep learning curve.

What does that mean??
Perhaps the word "stupid" should only appear after the third <enter>?

If the OP follows my suggestion on the code tweaks nothing happens when
enter is hit.

If he also takes the time to explain respectfully how and why the new
interface is different no one ever needs to be called stupid, especially not
by a mere computer.
My way they would not see those two alerts any more in an hour,
and also target the ones that are on holyday, congress, ill, sick,
buzy elsewhere or just too sleepy during your "conference room with a
projector" happening to notice.

However, in a setting where money is no object, and absolute politeness
is, your idea might eventually work.

Since I have actually managed people and have had to do things similar to
that in the past I can tell you it isn't expensive or pointless and it does
work. People should treat people with respect, computers should treat
people like gods.
 
B

Bob Barrows [MVP]

Anthony said:
Makes you wonder what they were using before that taught them to use
the enter button.

?
Most Windows apps: Excel, Access, etc., use the Enter key for field/cell
navigation. Even Word: you press Enter to get to a new line, not Tab.
:) It sounds like you turned on your first computer to a browser and ran
nothing except that for your entire computing life ... ;-)
 
E

Evertjan.

Anthony Jones wrote on 12 jul 2007 in
microsoft.public.inetserver.asp.general:
What does that mean??

Seems I cann't help you there.
If the OP follows my suggestion on the code tweaks nothing happens
when enter is hit.

If he also takes the time to explain respectfully how and why the new
interface is different no one ever needs to be called stupid,
especially not by a mere computer.


Since I have actually managed people and have had to do things similar
to that in the past I can tell you it isn't expensive or pointless and
it does work. People should treat people with respect, computers
should treat people like gods.

Wow, then we should not take the most used OS as an example.

I suppose you also tried to do it the way I suggested,
or else you wouldn't know from experience.

btw, do you expect everyone to be serious? ;-)
 
A

Anthony Jones

Bob Barrows said:
?
Most Windows apps: Excel, Access, etc., use the Enter key for field/cell
navigation. Even Word: you press Enter to get to a new line, not Tab.

None of the above are good analogies of standard computer form based system.

In Word the tab key follows the same function that it does on a typewriter.
It moves to the next tab stop.
Pressing enter or return starts a new line similar to what happens in on a
typewriter. There is no concept here of the next field or control to move
to.

In Excel the tab key always moves to the next cell to the right. Again with
its origins on the typewriter this is natural. If you do that a few times
and hit enter see what happens, it goes to the cell under the cell which you
were in when you first started your series of tabs. It is true that enter
can move to the next cell on the right if the that seems to be what you want
currently. But it can also will move you to the row. It just makes enter
key behaviour quirky and less predictable.

However open any dialog on these apps and hit enter what happens? Compare
that with hitting Tab in those dialogs? (In fact you can click in one of
the tool bar embedded controls and try the same tests). The truth is nearly
every windows app that displays an actionable set of controls uses enter to
submit (if it has a default button) and tab to move between controls.
:) It sounds like you turned on your first computer to a browser and ran
nothing except that for your entire computing life ... ;-)

Actually my first experience of this pre-dates windows. Big-iron IBM
systems for Bill of Materials and stock control. The old 3270 terminals
would again use tab to move between the fields and enter to submit the page.
It is this standard that Windows adopted and MS published in design
guidelines. It has become the industry accepted standard.

I know I am _that_ old. ;)
 
A

Anthony Jones

Evertjan. said:
Anthony Jones wrote on 12 jul 2007 in
microsoft.public.inetserver.asp.general:


Seems I cann't help you there.


Wow, then we should not take the most used OS as an example.


I suppose you also tried to do it the way I suggested,
or else you wouldn't know from experience.

btw, do you expect everyone to be serious? ;-)

I can't tell when you're being serious or not. Partly because the text
medium removes much from communication and partly because I do tend to be a
literal thinker.
 
B

Bob Barrows [MVP]

Anthony said:
None of the above are good analogies of standard computer form based
system.

In Word the tab key follows the same function that it does on a
typewriter. It moves to the next tab stop.
Pressing enter or return starts a new line similar to what happens in
on a typewriter. There is no concept here of the next field or
control to move to.

In Excel the tab key always moves to the next cell to the right.

So does Enter, which is a boon for people entering a lot of numeric
data.

Open Calculater and perform this calculation without using the mouse:
4+5*9=
What key did you press instead of clicking the "=" button? I doubt it
was tab ;-)

Think of an accountant entering a list of numbers from a printout or a
bunch of receipts or invoices: she will use her left hand to keep track
of where she is, and her right hand to enter the values using the number
pad. Think of the loss of productivity if she had to use the Tab key
instead of the Enter key on the number pad.
 
D

Dave Anderson

Anthony said:
...Apologise prefusely to them for having them use an
application in the past that did not conform to this
standard and could they please use the tab button from
now on.

Yeah - just because their telnet/3270 applications were designed and written
before the web browser even existed, those old programs should have gotten
with the eventually-to-become-standard program.
 
M

MichaelK

Wow guys, didn't expect such a dispute on this easy question.

Well, here's my point of view on this.

First - you are not always free what you want.
If your boss told you to do so, I guess it doesn't matter how smart you are
guys.
Second - people are changing there too often, so really don't want to end up
hanging in the conference room learning pushing tabs more time then doing
the job.
Fourth - the forms I was talking about are shown up in the webbrowser
controls embedded in the regular VB forms. Regardless how weird it sounds
for some it works perfectly for us. At the same time people dealing with the
Unix based applications and old VB programs, and everywhere they are using
Enter as a standard key, and it's not easy for them to switch on Tab when
they got on the HTML forms.
Fifth - it's such a small correction, and was much easier to do, then listen
complains every day. Now every one is happy, we moved on and forgot this
problem ever existed. Have too many other things to work on.

At the end I don't make those programs for myself, but for people who use
them.
They order the music, and in this particular case I don't see they are that
wrong.
But even so why would I jump over my head proving they are wrong.

Just love to listen the people who spent the life in software development
groups or college teachers and hear how everything should be done right. Was
there. Always want to put them in the real intense production environment
where people have deal with the hundreds of applications running in unix,
windows, intranet, extranet, some seems older then I am, written in
different languages, storing data in different formats. And you need to fix
something right here right now.

Dam, it was too long, hope it wont fire another discussion.
Regards :)
Michael
 
A

Anthony Jones

MichaelK said:
Wow guys, didn't expect such a dispute on this easy question.

Well, here's my point of view on this.

First - you are not always free what you want.
If your boss told you to do so, I guess it doesn't matter how smart you are
guys.

That's fine if it is the decision of the management. As I said the fault
will be with them as long as you have explained clearly that this design
choice is non-standard and could well cause problems in the future, its up
to them to decide what is overall in the best interests of the company
Second - people are changing there too often, so really don't want to end up
hanging in the conference room learning pushing tabs more time then doing
the job.

Thing is if other people join the company from other data entry posts which
key do you think they will be used to using for field navigation? Currently
they are picking up that the enter is being used here by what ever training
you give them when they join, you do train them right?

You only need to do the conference room thing once. After all the tab key
isn't the only thing that's going to change. You're not going to change
the app without informing them in some way. Getting them together and
explaining the changes and the reasons for them may not be absolutely
necessary but it's good people management. It makes a bit of change to
their routine and if done right makes them feel involved. I know this is
not your decision but it's worth suggesting.

Fourth - the forms I was talking about are shown up in the webbrowser
controls embedded in the regular VB forms. Regardless how weird it sounds
for some it works perfectly for us. At the same time people dealing with the
Unix based applications and old VB programs, and everywhere they are using
Enter as a standard key, and it's not easy for them to switch on Tab when
they got on the HTML forms.

Now that's a good pragmattic reason. It might have been handy had you
mentioned it in an earlier post. It is showstopper. ;)
Fifth - it's such a small correction, and was much easier to do, then listen
complains every day.
Now every one is happy, we moved on and forgot this
problem ever existed. Have too many other things to work on.

How small a correction is it? I'd be interested to see what the code looks
like that solves this problem?
I don't think it is that small but in light of point 4 it would seem to be
worthwhile.
At the end I don't make those programs for myself, but for people who use
them.
They order the music, and in this particular case I don't see they are that
wrong.
But even so why would I jump over my head proving they are wrong.

Just love to listen the people who spent the life in software development
groups or college teachers and hear how everything should be done right. Was
there. Always want to put them in the real intense production environment
where people have deal with the hundreds of applications running in unix,
windows, intranet, extranet, some seems older then I am, written in
different languages, storing data in different formats. And you need to fix
something right here right now.

Yikes what a nightmare! I've never come across an environment where users
are expected to use 'hundreds' of such disparate applications. (and all
them use enter key for navigation at that)

I can see why you would want the simplest no hassle solution to all
problems.
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top