473,326 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 10036
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
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
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
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
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
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
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
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
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
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.