Solved

Default button

Posted on 2003-11-17
6
336 Views
Last Modified: 2010-04-09
I have two text boxes and a button. i want the button to be able
to be utilized by pressing the enter key. how do i do this?

<input type=button value="Login" onClick="Login()">
0
Comment
Question by:Mike Miller
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 9765265
Here is a working example for IE:

<HTML>
<HEAD>
<SCRIPT language="javascript">
 function Login()
 {
    alert(0);
    return false;
 }
</SCRIPT>
</HEAD>

<BODY>
<FORM name="myform" action="javascript:alert('Submitted');" >

  <input type="text" name="userName" />
  <input type="text" name="password" onkeyup="if(event.keyCode==13)this.form.submit();" />
  <input type="button" value="Login" onClick="Login()" />

</FORM>
</BODY>
</HTML>
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9765273
if the user tabs to the button, and presses enter it will "click it" and do your Login function

0
 
LVL 33

Expert Comment

by:knightEknight
ID: 9765275
oops, but my Login function is just a stub -- obviously, you should replace it with your own.  The key is in the onkeyup event handler.  I am working on a NS version too...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 33

Expert Comment

by:knightEknight
ID: 9765287
This one should work in NS too:

 <input type="text" name="password" onkeyup="var event = e?e:event; if(event.keyCode==13)this.form.submit();" />
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 9765359
oops, scratch that last post ... go with the first one instead.
0
 
LVL 3

Accepted Solution

by:
monvelasquez earned 50 total points
ID: 9768159
would it be ok if you do it like this...

Here is a working example for IE:

<HTML>
<HEAD>
<SCRIPT language="javascript">
 function Login()
 {
    alert('Submitted');
    return false;
 }
</SCRIPT>
</HEAD>

<BODY>
<FORM name="myform" action="javascript:Login();" >

  <input type="TEXT" name="userName" />
  <input type="PASSWORD" name="password" />
  <input type="SUBMIT" value="Login" />

</FORM>
</BODY>
</HTML>
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need to add another Column in Powershell script output 2 33
Accordion won't close correctly 5 14
html form layout 4 36
How do I update select listbox after search 2 25
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Find out what you should include to make the best professional email signature for your organization.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question