[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Default button

Posted on 2003-11-17
6
Medium Priority
?
341 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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 200 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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

830 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