...

View Full Version : Using Enter Key to activate



rkuhlen
12-22-2003, 08:03 PM
I would like this script to be activated when the user hits the enter key. Now the user needs to click on the Log In button. What do I need to change?

++++++++++

<form>
<p><FONT FACE="Verdana,Tahoma,Arial,Helvetica,Sans-serif,sans-serif" SIZE="-1"><b> LOG IN HERE.</b></p>
Username and Password are <b>CAsE sENisTIvE</b><br>
<p>ENTER USERNAME :
<input type="text" name="text2">
</p>
<p> ENTER PASSWORD :
<input type="password" name="text1">
<input type="button" value="Log In" name="Submit" onClick=javascript:validate(text2.value,"TEST",text1.value,"TEST") ></FONT>
</p>

</form>
<script language = "javascript">

/*
Script by Anubhav Misra (anubhav_misra@hotmail.com)
Submitted to JavaScript Kit (http://javascriptkit.com)
For this and 400+ free scripts, visit http://javascriptkit.com
*/

function validate(text1,text2,text3,text4)
{
if (text1==text2 && text3==text4)
load('ing-gm.html');
else
{
load('failure.htm');
}
}
function load(url)
{
location.href=url;
}
</script>

Choopernickel
12-22-2003, 08:28 PM
Step one: Valid HTML.
Step two: Format with CSS.
Step three: Make sure the form responds without scripting enabled.


<html>
<head>
<script type="text/javascript">
/*
Script by Anubhav Misra (anubhav_misra@hotmail.com)
Submitted to JavaScript Kit (http://javascriptkit.com)
For this and 400+ free scripts, visit http://javascriptkit.com
*/
function validate(text1,text2,text3,text4) {
if (text1==text2 && text3==text4) {
location.href = 'ing-gm.html';
} else {
location.href = document.forms[0].action;
}
return false;
}
</script>
<style type="text/css">
p {
font-family: Verdana,Tahoma,Arial,Helvetica,sans-serif;
font-size: 91%;
}
</head>
<body>
<form action="failure.htm" onsubmit="return validate(text2.value,'TEST',text1.value,'TEST');">
<p><em>LOG IN HERE.</em></p>
<p>Username and Password are <em>CAsE sENisTIvE</em></p>
<p>ENTER USERNAME :
<input type="text" name="text2">
</p>
<p>ENTER PASSWORD :
<input type="password" name="text1">
<input type="submit" value="Log In">
</p>

</form>
</body>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum