View Full Version : Help with my script

12-13-2009, 03:18 PM
Hey guys,
I'm new around here, and I would like some help. :)

This is the code :
<script language="javascript">
/*This Script allows people to enter by using a form that asks for a
UserID and Password*/
function pasuser(form) {
if (form.id.value=="VIP") {
if (form.pass.value=="16320606") {
} else {
alert("Invalid Password")
} else { alert("Invalid UserID")
<form name="login" onsubmit="pasuser(this.form)">
<span class="style13">Username: </span>
<input name="id" type="text" size="15">
<span class="style13">Password: </strong></span>
<input name="pass"type="password" size="15">
<input type="submit" value="Login">

How would I make this redirect to a different page after an invalid password was entered?

And is it possible to remove the User ID, option entirely? Can I just have a password option?

12-13-2009, 03:58 PM
This script is a horrible idea. Anyone viewing the page's source code can get the password and then enter your adminspalace.htm page. Also, they could just look and see the name of the page and enter it directly into the browser's address bar to navigate to it without filling out the form.

Server side code should be used for this type of thing.

That said, this would do as you say you want:

<script type="text/javascript">
/* This Script allows people to enter by using a form that asks
for a Password or by viewing the page's source code */
function passwrd(form){
if(form.elements.pass.value === '16320606'){
location = 'adminspalace.htm';
} else {
alert('Invalid Password');
location = 'someother.htm';
return false;
<form action="#" name="login" onsubmit="return passwrd(this.form)">
<span class="style13">Password: </span>
<input name="pass" type="password" size="15">
<input type="submit" value="Login">