JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old February 6th, 2006, 12:59 PM
nevillemehta nevillemehta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: India
Posts: 64 nevillemehta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 44 m 17 sec
Reputation Power: 6
Call Event on Pressing Enter Key...

Hi,

I have a textfield which asks for an email address. I want a popup to open as soon as the user clicks on enter in the textfield. onClick ofcourse wont work cause the popup pops up even when i focus on the textfield to enter the email address. Any solution, maybe an event like onEnter???

thanks
Neville

Reply With Quote
  #2  
Old February 6th, 2006, 01:29 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Instead of enter, you might want to use onBlur. This way, if the user presses tab, or clicks somewhere else on the page, your function will still be called.

Code:
<input type="text" name="whatever" onblur="alert(this.value)" />

Pressing enter in a FORM is often similar to submitting.
You may want to use onSubmit (on the FORM tag)... depends on your ultimate goal.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter!
DevArticles Forum Moderator

"The net is a waste of time, and that's exactly what's right about it." -- William Gibson

Reply With Quote
  #3  
Old May 6th, 2006, 04:10 AM
eralpery eralpery is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 16 eralpery User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 19 m 57 sec
Reputation Power: 0
Hi,

You can use onkeydown attribute to fetch the event and check it in a script that I've written down below.

You can find a list of key codes and a runnins sample script how to find key codes can be found at http://www.kodyaz.com/content/HowToGetKeyCodesList.aspx


I hope it helps.

<script>
function PopUpEmail(e){

if(e){
e = e
} else {
e = window.event
}

if(e.which){
var keycode = e.which
} else {
var keycode = e.keyCode
}

if(keycode == 13) {
alert("Open your Popup Screen")
}
}
</script>

<input type=text name=email onkeydown="PopUpEmail(event)">


Eralper
http://www.eralper.com

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Call Event on Pressing Enter Key...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway