473,511 Members | 16,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hitting Enter on a single text box

these 3 lines will put the following into the URL bar!
but with 2 input boxes it doesn't.

<form name=test>
<INPUT name='selqty2'>
</form>

file:///C:/WINDOWS/DESKTOP/tttt2.html?selqty2=55555
Is there a way to stop the URL bar changing and the page refreshing
when people press Enter on a single text input?

Herc

--
Yeah, I guess you're right.
Top posting can make things confusing.

What's wrong with top posting?

Jul 20 '05 #1
3 10047
VK
Yes, it's the default behavior. If there is only one single-line text
box in the form and you press Enter in it, it submits the form. Look at
the Google or any other search engine - you are using it everyday.

I'm not sure what do you expect in your case. If you just want to
disregard the Enter hits, try this:
<form onSubmit="return false;">
<input type="text" name="selqty2">
</form>


|-|erc <us*************@wwwadamskingdom.com> wrote in message
news:BM****************@nnrp1.ozemail.com.au...
these 3 lines will put the following into the URL bar!
but with 2 input boxes it doesn't.

<form name=test>
<INPUT name='selqty2'>
</form>

file:///C:/WINDOWS/DESKTOP/tttt2.html?selqty2=55555
Is there a way to stop the URL bar changing and the page refreshing
when people press Enter on a single text input?

Herc

--
Yeah, I guess you're right.
Top posting can make things confusing.

What's wrong with top posting?


Jul 20 '05 #2
"|-|erc" <us*************@wwwadamskingdom.com> writes:
these 3 lines will put the following into the URL bar!
but with 2 input boxes it doesn't.
Actually, it does it with two input boxes too in my browser.
<form name=test>
<INPUT name='selqty2'>
</form>

file:///C:/WINDOWS/DESKTOP/tttt2.html?selqty2=55555 Is there a way to stop the URL bar changing and the page refreshing
when people press Enter on a single text input?


Pressing enter in a text input box will submit the form it is in.
Your form doesn't have an action attribute, which is required in HTML.
That is, your HTML is invalid. Fix that before going any further.

If you don't want to submit the form, you shouldn't have a form
element at all. (Generally, if you have an element and want to leave
out a required attribute, you are probably using it incorrectly.)

There is ofcourse the problem that Netscape 4 only accepts form
controls inside a form element. That means that if your page must
work in Netscape 4 (which is a browser so far from modern standards
that it ought to be dead and buried long ago), you must have the
form element.

A form control without a form is legal HTML. There is no way to submit
it, so you are probably using Javascript to access the control. That
means that your page depends on Javascript.

What you can do to make both Netscape and the HTML specification
happy, is to add an action attribute that directs the user to a page
that tells him why your page requires Javascript, and then use
Javascript to prevent the form from being submitted.

<form id="test" action="noJS.html" onsubmit="return false">
<input name="selqty2">
</form>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
"Lasse Reichstein Nielsen" <lr*@hotpop.com> wrote in
"|-|erc" <us*************@wwwadamskingdom.com> writes:
these 3 lines will put the following into the URL bar!
but with 2 input boxes it doesn't.


Actually, it does it with two input boxes too in my browser.
<form name=test>
<INPUT name='selqty2'>
</form>

file:///C:/WINDOWS/DESKTOP/tttt2.html?selqty2=55555

Is there a way to stop the URL bar changing and the page refreshing
when people press Enter on a single text input?


Pressing enter in a text input box will submit the form it is in.
Your form doesn't have an action attribute, which is required in HTML.
That is, your HTML is invalid. Fix that before going any further.

If you don't want to submit the form, you shouldn't have a form
element at all. (Generally, if you have an element and want to leave
out a required attribute, you are probably using it incorrectly.)

There is ofcourse the problem that Netscape 4 only accepts form
controls inside a form element. That means that if your page must
work in Netscape 4 (which is a browser so far from modern standards
that it ought to be dead and buried long ago), you must have the
form element.

A form control without a form is legal HTML. There is no way to submit
it, so you are probably using Javascript to access the control. That
means that your page depends on Javascript.

What you can do to make both Netscape and the HTML specification
happy, is to add an action attribute that directs the user to a page
that tells him why your page requires Javascript, and then use
Javascript to prevent the form from being submitted.

<form id="test" action="noJS.html" onsubmit="return false">
<input name="selqty2">
</form>


nice detective work, return false works thanks to both of you.

Herc

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3798
by: ritelman | last post by:
Hi I have one text field and one submit button. If I hit the submit button with a mouse the key/value pair key are properly submitted. However, if I just hit the enter key the page does get...
10
4367
by: Deano | last post by:
I think that just about sums it up. Is there a fix/workaround for this?It's quite annoying behaviour and not user-friendly.thanksMartin
2
1228
by: Mark Allison | last post by:
Hi, On my Windows Form I have a text control and a button. The text control is single-line and I want the user to be able to type something in it, but when they hit Enter, I want this to click...
9
1868
by: Nate Hekman | last post by:
As I've mentioned a couple of times in the last few minutes(!), I've got a simple form with an edit box and a Submit button. If I type something in the Edit box and hit Enter I hear a click but...
2
3105
by: 23s | last post by:
My site's login page has a form w/ 2 textboxes and a submit button. If I'm in either of those textboxes (i.e., either one of the textboxes has focus), in any given browser, hitting "enter" on my...
5
22694
by: Dundealing | last post by:
I have a single button on my form, and when I press the Enter key while a TextBox has focus I want the Button.Click event to fire. Is there a simple way to do this ?
4
2743
by: sowencheung | last post by:
Hi, all The scenario is like this: I have a master page, contains two user controls, one is a search control, another is a login control. The server-side <form> is in the master page,...
6
4912
by: Paul Furman | last post by:
I'm getting incorrect response when hitting the enter key instead of actually clicking the button on a form. It activates but the post data isn't being sent I think. The php generated page...
2
1663
by: Sunfire | last post by:
I was wondering if there was a way to hit enter to insert blank lines while in the designer? I tried this but all it seems to want to do is insert code that really shouldn't be there. For example,...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5662
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.