Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On Keypress loading same page But need to submit text field

Status
Not open for further replies.

werD420

Technical User
Joined
Sep 14, 2004
Messages
181
Location
US
Hey all
Im kind of a noob at java but im catching on fast Just need a little help with one problem I have a site with a direct dialer on it(type in a number it takes you to the site)
It works great...if i hit the button or hit tab but when I hit enter the page refreshes. I have tried a few scripts but have yet to be able to get enter to function properly i would appreciate it
The end result intended is chknum(document.board.pn.value)
I would appreciate any help at all thanks
 
It sounds like you're talking about JavaScript, in which case:

To DISABLE form-submission upon hitting enter-key in text field:

<input type='text' size='30' onkeydown='if(event.keyCode==13)return false;'/>

(Note: I think keyCode is IE-specific).


If you want the correct thing to happen when you hit 'Enter,' then update the document's FORM tag to:

<form name='board' onsubmit='return chknum(document.board.pn.value)'>

And update chknum to return false if the JavaScript indicates a reason to NOT submit the form.

Apologies in advance if I've totally misunderstood your question. This just sounds like JavaScript you're talking about... an extremely different animal than Java.

--Dave

 
Like I said Im a noob I am looking for java script code and you hit my nail right on the head... just one problem. Now I can hit enter and pull up the intended page but it simultaneously pulls up the exact page that you are on in a different window and the site you were dialing in the same. I do not want the pop up to happen but cant find anything that would be making it do this. Any help at all would be much appreciated thanks
 
Go to forum216 and post your source code there, asking the same question. I would want to see your code anyway and this really isn't the right forum for this.

--Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top