...

View Full Version : Javascript Username login help



wilsonmartin
03-16-2005, 02:21 PM
Hello everyone,

I am trying to do a username login for my webpage with Javascript and I can only get one user in, I have tried to add on various other users and it does not work. Could anyone lend me a hand in figuring this out, I want to add other usernames and passwords and I simply am not accomplishing it. Whoever can help me I would greatly appreciate it.

God Bless!

Will

Here is the Code:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Javascript Test</title>
<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
}
-->
</style>
</head>

<body class="style1">
<form>
<p>ENTER USER NAME :
<input type="text" name="text2">
</p>
<p> ENTER PASSWORD :
<input type="password" name="text1">
<br>
<input type="button" value="Check In" name="Submit" onclick=javascript:validate(text2.value,"free",text1.value,"javascript") >
</p>

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

function validate(text1,text2,text3,text4)
{
if (text1==text2 && text3==text4)
load('http://www.yahoo.com');
else
{
load('failure.htm');
}
}
function load(url)
{
location.href=url;
}
</script>
</body>
</html>

A1ien51
03-16-2005, 02:26 PM
Welcome to the forum, I see you did not read the bold text that siad this forum is for completed scripts not questions. A moderate will most likely move this....

I am too lazy to run your code, but I see a flaw in how you are referencing the form field values.

You should reference them like
document.formName.elementName.value

an not

elementName.value

you do not have a name with your form either...you could use the form array, but it is better to have a name.

AND finally

when using evernt handlers like onclick you do not need javascript:
onclick='validate(.....)'

Eric



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum