473,672 Members | 2,511 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?selq ty2=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 10060
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="retur n false;">
<input type="text" name="selqty2">
</form>


|-|erc <us************ *@wwwadamskingd om.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?selq ty2=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************ *@wwwadamskingd om.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?selq ty2=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.ht ml" onsubmit="retur n 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************ *@wwwadamskingd om.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?selq ty2=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.ht ml" onsubmit="retur n 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
3805
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 submitted however without the key/value pair of the submit button. I would accept that a user must click the button to submit the pair, but none of my other pages require that. It seems if I just hit the enter key it defaults to hitting the submit...
10
4382
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
1233
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 the button, (so the user doesn't have to click the button using a mouse). How do I do that? Thanks.
9
1873
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 nothing happens. If I click on the Submit button its Click event fires as I'd expect. If I click anywhere else on the web page and then hit Enter, the button's Click event fires too. I want the Click event to fire when the user is in the Edit...
2
3111
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 keyboard submits the form. Server side, I handle the click event of the submit button. This is the expected behavior, and this is the behavior irrespective of what browser I use on the login page. However... I have different page that is an...
5
22707
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
2749
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, that's of course. It seems the search control is rendered first, when I stay in the
6
4929
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 flickers & reloads but doesn't perform the update. This is php generated, I'm just pasting the page source (reformatted & extra junk removed and I think they are now identical), and it's running on my localhost apache server for testing so maybe...
2
1672
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, I had a heading 1 centered on a page. Right under that I had some words in smaller print right under the heading. When I hit enter after the heading 1, it automatically put the text right below it in a <p></ptag. I don't want this sort of stuff to...
0
8485
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8403
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8828
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8677
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5704
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2819
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.