Solved

Default button

Posted on 2003-11-17
6
332 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:mwmiller78
  • 4
6 Comments
 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
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
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 33

Expert Comment

by:knightEknight
Comment Utility
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
Comment Utility
oops, scratch that last post ... go with the first one instead.
0
 
LVL 3

Accepted Solution

by:
monvelasquez earned 50 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now