Click to See Complete Forum and Search --> : JavaScript: require code for userid & password on website (html)


n@dia
11-12-2003, 12:55 AM
Req code into html page enable login using ms access database with userid & password. following code leeds to error on page....
______________________________________________________
Header:

<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=="michelle") {
if (form.pass.value=="justin") {
location="target.html"
} else {
alert("Invalid Password")
}
} else { alert("Invalid UserID")
}
}
//-->
</script>

Body:

<B>Login
Area</b>
<i><B>UserID:</b></i><Form name="login"><input
name="id" type="text">
<i><B>Password:</b></i><input name="pass"
type="password">
<input type="button" value="Login"
onClick="pasuser(this.form)"><Br><input
type="Reset"></form>
_______________________________________________
Your experience in this matter would be greatly appreciated!
PS. html page attached.
Regards
Nadia

Gollum
11-12-2003, 02:08 AM
Without knowing what error you are seeing I can only guess as the code you have posted seems to work as intended for me (IE can be so lax sometimes).

However, I suggest you change your function like this to use 'document.login' instead of 'form'

function pasuser(form)
{
if (document.login.id.value=="michelle")
{
if (document.login.pass.value=="justin")
{
location="target.html"
}
else
{
alert("Invalid Password")
}
}
else { alert("Invalid UserID")
}
}

n@dia
11-13-2003, 12:38 AM
Thank you for posting to this question, could I ask you to pease see amended html page attached, since I still get error?

Regards
Michelle
RSA

beastman
03-01-2008, 08:45 AM
your password is 2 long, it can't contain more than 6 chars "michelle" should be "michel", justin is fine. however, i don't recommend using this type of validation because anyone with a little websitedeveloppigexperience can hack that

just go to view source code and you can see it

you can even see the site it if reffering to

http://digg.com/programming/How_NOT_to_secure_your_website