Connecting Tech Pros Worldwide Forums | Help | Site Map

when i create single text box on page and press enter the page refresh ?

Newbie
 
Join Date: Nov 2006
Posts: 5
#1: Nov 24 '06
hi everyone

when i create single text box on page and press enter the page refresh how can i stop to refresh the page....

dhiraj
dswethar's Avatar
Member
 
Join Date: Nov 2006
Location: UK
Posts: 68
#2: Nov 24 '06

re: when i create single text box on page and press enter the page refresh ?


Hi,

What is the value of your ACTION in the form tag?
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#3: Nov 26 '06

re: when i create single text box on page and press enter the page refresh ?


Make a JavaScript routine that captures (onkeypress) the ENTER keystroke and ignores it.

Ronald :cool:
Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#4: Nov 28 '06

re: when i create single text box on page and press enter the page refresh ?


You are probably submitting your form if you have <input type="submit" value="submit" /> change it to <input type="button" ....
Newbie
 
Join Date: Nov 2006
Posts: 5
#5: Dec 5 '06

re: when i create single text box on page and press enter the page refresh ?


Quote:

Originally Posted by dswethar

Hi,

What is the value of your ACTION in the form tag?

i send u a simple code when u run this and press enter in the text box it refresh the page,i want to stop this refresh action.

<HTML>
<HEAD>

</HEAD>

<BODY>
<form name="searching">
<input type="text" id="abc" >
</form>
</BODY>
</HTML>
Newbie
 
Join Date: Nov 2006
Posts: 5
#6: Dec 5 '06

re: when i create single text box on page and press enter the page refresh ?


i send u a simple code when u run this and press enter in the text box it refresh the page,i want to stop this refresh action.

<HTML>
<HEAD>

</HEAD>

<BODY>
<form name="searching">
<input type="text" id="abc" >
</form>
</BODY>
</HTML>
Newbie
 
Join Date: Nov 2006
Posts: 5
#7: Dec 5 '06

re: when i create single text box on page and press enter the page refresh ?


Quote:

Originally Posted by dswethar

Hi,

What is the value of your ACTION in the form tag?

i send u a simple code when u run this and press enter in the text box it refresh the page,i want to stop this refresh action.

File Name :test.jsp
inside test.jsp
<HTML>
<HEAD>

</HEAD>

<BODY>
<form name="searching">
<input type="text" id="abc" >
</form>
</BODY>
</HTML>
Run this file on Apache Tomcat (web server)
Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#8: Dec 5 '06

re: when i create single text box on page and press enter the page refresh ?


Whats with the triple posting?
Newbie
 
Join Date: Nov 2006
Posts: 5
#9: Dec 5 '06

re: when i create single text box on page and press enter the page refresh ?


Quote:

Originally Posted by AricC

Whats with the triple posting?

sorry for triple posting my page generate error due to that it .......i think that it cannot posted so i submit three times...
Expert
 
Join Date: Oct 2006
Location: NC
Posts: 1,722
#10: Dec 5 '06

re: when i create single text box on page and press enter the page refresh ?


I don't see anything in your code that would make it behave that way????
Newbie
 
Join Date: Jul 2008
Posts: 1
#11: Jul 14 '08

re: when i create single text box on page and press enter the page refresh ?


From http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2 under "Form Submission":

"When there is only one single-line text input field in a form, the user agent should accept Enter in that field as a request to submit the form."

I found out about this when I found the page http://niwo.mnsys.org/saved/~flavell/www/formquestion.html
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#12: Jul 16 '08

re: when i create single text box on page and press enter the page refresh ?


Welcome to the site and thanks for the information.

To avoid this, capture the enter key press using JavaScript and disable the action with return false as ronverdonk mentioned many months ago.
Reply