|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
I'm trying to make this password thing and it doesnt work. I cant figure the thing our. I keep getting the error where i am calling the function at the onClick. I'm new to JavaScript and im still not sure about arguments. I think thats where its messing up. Also I saw var done = 0 and im not sure why that is there either. i got that from a website.
<!--PASSWORD FUNCTION--> <script language="javascriipt"> <!-- function passWord() { var done = 0; var userName = document.myForm.name.value; var pssWord = document.myForm.password.value; var id1 = tweeder; var id2 = dudley; var id3 = stevedog; var psw1 = 6904; var psw2 = 1323; var psw3 = 1111; if (userName=="id1" && pssWord=="psw1") { window.location="hank.htm"; done=1;} if (userName=="id2" && pssWord=="psw1") { window.location="hank.htm"; done=1;} if (userName=="id3" && pssWord=="psw3") { window.location="hank.htm"; done=1;} else { alert("Invalid Information") } } //--> </script> <form name="myForm"> <table border="1" cellspacing="0" cellpadding="3"> <tr> <td>ID: <div align="right"><input type="text" size="20" name="name"></div></td> </tr> <tr> <td>Password: <div align="right"><input type="password" size="20" name="password"></div></td> </tr> </table> <input type="button" value="Login" onClick="passWord()"> </form> |
|
#2
|
||||
|
||||
|
First off, um, don't use javascript to do your authentication. One needs only to read the source code to get into other areas of your site. Additionally, the pages you're redirecting to aren't secured, so anybody can read them.
That said, you might try either window.location.href or document.location.href rather than just window.location. Also, please try to use descriptive title lines in any future posts rather than something useless like "Hmm." |
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Hmm |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|