473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Use return Key to submit

I have a form on a web page that requires to click on a button to
submit the information. I have two questions about changing this form:
1. Is there a way that I can change the script so that the form can be
submitted by hitting the enter key?
2. Is there a way that I can have the Username and Password boxes
cleard after the form is submitted?

You probably don't need the code for the form as it is pretty basic but
here it is just in case. Thanks.

<form name=login>
<table width=225 border=1 cellpadding=3>
<tr><td colspan=2><center><font size="+2"><b>Bombers Only
Area!</b></font></center></td></tr>
<tr><td>Username:</td><td><input type=text name=username></td></tr>
<tr><td>Password:</td><td><input type=password name=password
size="20"></td></tr>
<tr><td colspan=2 align=center><input type=button value="Login!"
onClick="Login()"></td></tr>
</table>
</form>

Jan 17 '07 #1
3 5045

Anthony napísal(a):
I have a form on a web page that requires to click on a button to
submit the information. I have two questions about changing this form:
1. Is there a way that I can change the script so that the form can be
submitted by hitting the enter key?
2. Is there a way that I can have the Username and Password boxes
cleard after the form is submitted?

You probably don't need the code for the form as it is pretty basic but
here it is just in case. Thanks.

<form name=login>
<table width=225 border=1 cellpadding=3>
<tr><td colspan=2><center><font size="+2"><b>Bombers Only
Area!</b></font></center></td></tr>
<tr><td>Username:</td><td><input type=text name=username></td></tr>
<tr><td>Password:</td><td><input type=password name=password
size="20"></td></tr>
<tr><td colspan=2 align=center><input type=button value="Login!"
onClick="Login()"></td></tr>
</table>
</form>
the easiest way is to add onsubmit="Login(); return false;"

to erase values from form, just add inputobj.value="" to Login()
function.

Jan 17 '07 #2
I have another question for which I will give you some more background
info. I am using a external JS script that is called from a source
file on my website. This is the code:

function Login() {
var username=document.login.username.value.toLowerCase ();
var password=document.login.password.value.toLowerCase ();

for (i=0; i<userData.length; i++) {
if (username==userData[i] [0] && password==userData[i] [1]){
window.open(userData[i]
[2],"blank","toolbar=no,width=540,height=250,top=0,le ft=0");
return true;
}
}
alert("Invalid Login!");
}

I would like the window in the above function to open on "top" of the
login page of my website. When I use the input type=button it works
like I want but I HAVE to click on the Login! button which I am trying
to avoid. When I change to input type=submit, the new window opens up
briefly and then "hides" behind the page that holds the form. How do I
fix this or is it even possible? Thanks for taking the time to help.

zero0x wrote:
Anthony napísal(a):
I have a form on a web page that requires to click on a button to
submit the information. I have two questions about changing this form:
1. Is there a way that I can change the script so that the form can be
submitted by hitting the enter key?
2. Is there a way that I can have the Username and Password boxes
cleard after the form is submitted?

You probably don't need the code for the form as it is pretty basic but
here it is just in case. Thanks.

<form name=login>
<table width=225 border=1 cellpadding=3>
<tr><td colspan=2><center><font size="+2"><b>Bombers Only
Area!</b></font></center></td></tr>
<tr><td>Username:</td><td><input type=text name=username></td></tr>
<tr><td>Password:</td><td><input type=password name=password
size="20"></td></tr>
<tr><td colspan=2 align=center><input type=button value="Login!"
onClick="Login()"></td></tr>
</table>
</form>

the easiest way is to add onsubmit="Login(); return false;"

to erase values from form, just add inputobj.value="" to Login()
function.
Jan 17 '07 #3
ASM
Anthony a écrit :
I have another question for which I will give you some more background
info. I am using a external JS script that is called from a source
file on my website. This is the code:
What is your site ?
With this code it's really too easy to log under a stolen pseudo ! !
We only need to get userData ... :-(
function Login() {
var username=document.login.username.value.toLowerCase ();
var password=document.login.password.value.toLowerCase ();

for (i=0; i<userData.length; i++) {
if (username==userData[i] [0] && password==userData[i] [1]) {
window.open(userData[i]
[2],"blank","toolbar=no,width=540,height=250,top=0,le ft=0");
return false;
}
}
alert("Invalid Login!");
return false;
}

I would like the window in the above function to open on "top" of the
login page of my website.
What 'top of page' does mean for you ?
Don't you mean 'to open a popup' ? (at front of the main window)
In JS 'top' is the main page in a framed page.
When I use the input type=button it works
like I want but I HAVE to click on the Login! button which I am trying
to avoid.
if you have :
<form onsubmit="return Login();">
<input type=submit value="Validate">
you need no Login! button ... !
When I change to input type=submit, the new window opens up
briefly and then "hides" behind the page that holds the form.
If you ask to open a new window via submit button you must avoid action
of the form,
this is accomplished by form's onsubmit which returns 'false'.

zero0x wrote:
>Anthony napísal(a):
>>I have a form on a web page that requires to click on a button to
submit the information. I have two questions about changing this form:
1. Is there a way that I can change the script so that the form can be
submitted by hitting the enter key?
If one of the text fields has focus, pressing Enter key will submit,
it's a normal feature
(NC4 did so if the form has only one text field)

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Jan 18 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Don | last post by:
I want the server-side php script to return a browser page that is essentially a copy of the original client page that contained the <form> which referenced the php script in the first place....
3
by: Varun | last post by:
Hi There, I have a form("myRequest.asp") and the values from it are retrieved into the page ("output_Print.asp") on which I have two buttons('Save As Complete' and 'Save As Incomplete'). When the...
4
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
7
by: sindre | last post by:
Hi, Some place I use links to submit forms instead of a submit button. The way I have done this is: <a href="javascript:document.getElementById('<?php print "delete$i"...
1
by: Piotr | last post by:
I have popup window (window.open) where I put any value in input field. After submit I wan to to return to the main window and get value from popup window. How to close popup window and return to...
5
by: siaj | last post by:
Hello, I have a javascript function for a validation in the HTML page of the asp.Net page.. I call this function in a Savebutton click When the validation fails No postback should happen ( ie...
4
by: d3vkit | last post by:
I have a form on my page, and some javascript which uses ajax to submit the form, and then opens the new page in a div using ajax so there is no refresh. This works fine. But the problem is this: all...
8
by: Peter Afonin | last post by:
Hello, I'm using Javascript in ASP.NET application to check whether at least one checkbox in datagrid has been checked. If validation fails, the user gets a warning. If he clicks OK, the form is...
10
by: Tim Streater | last post by:
I have a form and a button to submit it. The button is made from: <input type=button onclick='myHandler(this.form);'> This all works fine except that in Safari 2.0.4, the enter/return keys, if...
5
by: GiJeet | last post by:
Hello, I'm trying to figure this code out. <input type="submit" onclick="if(!confirm('Are you sure?') return false; "... /> I know that if you return false in an event like this onclick it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.