473,699 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><cent er><font size="+2"><b>Bo mbers Only
Area!</b></font></center></td></tr>
<tr><td>Usernam e:</td><td><input type=text name=username></td></tr>
<tr><td>Passwor d:</td><td><input type=password name=password
size="20"></td></tr>
<tr><td colspan=2 align=center><i nput type=button value="Login!"
onClick="Login( )"></td></tr>
</table>
</form>

Jan 17 '07 #1
3 5060

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><cent er><font size="+2"><b>Bo mbers Only
Area!</b></font></center></td></tr>
<tr><td>Usernam e:</td><td><input type=text name=username></td></tr>
<tr><td>Passwor d:</td><td><input type=password name=password
size="20"></td></tr>
<tr><td colspan=2 align=center><i nput 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=docume nt.login.userna me.value.toLowe rCase();
var password=docume nt.login.passwo rd.value.toLowe rCase();

for (i=0; i<userData.leng th; i++) {
if (username==user Data[i] [0] && password==userD ata[i] [1]){
window.open(use rData[i]
[2],"blank","toolb ar=no,width=540 ,height=250,top =0,left=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><cent er><font size="+2"><b>Bo mbers Only
Area!</b></font></center></td></tr>
<tr><td>Usernam e:</td><td><input type=text name=username></td></tr>
<tr><td>Passwor d:</td><td><input type=password name=password
size="20"></td></tr>
<tr><td colspan=2 align=center><i nput 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=docume nt.login.userna me.value.toLowe rCase();
var password=docume nt.login.passwo rd.value.toLowe rCase();

for (i=0; i<userData.leng th; i++) {
if (username==user Data[i] [0] && password==userD ata[i] [1]) {
window.open(use rData[i]
[2],"blank","toolb ar=no,width=540 ,height=250,top =0,left=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="retur n 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
3094
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. However, the php script will need to change a couple html lines in that returned page. I sure could you some help on how to go about this. Thanks in advance, Don ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
3
4534
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 'Save as Incomplete' button is Clicked the form will be going to the "SaveAsincomplete.asp" without validation of the fields. And when the 'save as complete' is clicked certain fileds are to be validated and by the function return value, if false...
4
2336
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 need to: 1. Click a submit button on an asp page, calling another page that saves the contents of that form to a database and then displays
7
2000
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" ;?>').submit()>Delete?</a>. This method worked perfectly fine. But then I also wanted to add a confirm box to the user where. A confirm("do you really want to delete?"). So I made the function: function controll()
1
3431
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 the main after submit?
5
3962
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 Save should not happen) the js function is as function IsValidAmount() {
4
4971
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 values seem to pass except what the submit buttons say. I have a preview button and a finish button, and need to check which was pressed. I can add a checkbox for submit, but that's annoying. I'm using mootools for the ajax call, so it might not...
8
4370
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 submitted, if Cancel - nothing should happen. The ASP.NET code looks like this: btnSubmit.Attributes.Add("onClick", "if (!(" & sClientSideValidate.ToString
10
5525
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 pressed, submit the form - bypassing my onclick handler. I can partially fix this with: <form onsubmit='return false;'>
5
11659
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 prevents the default behavior of the event. So, in the onclick of a button the default behavior is to submit the form. Confirm returns the value 1 if the user clicks OK and the value 0 if
0
8613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8880
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7745
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.