JavaScript - Login Password Web Page
I have used the Java Script from your site:
http://www.javascriptkit.com/howto/htaccess3.shtml Evertime I enter the correct UserName and Password I get this Error: User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; Media Center PC 6.0) Timestamp: Sun, 16 Jan 2011 01:42:45 UTC Message: A security problem occurred. Line: 21 Char: 1 Code: 0 URI: file:///C:/test/htmllogin/login.htm Similar TutorialsFrom my main page, I have a dropdown-login box. Is it possible login form go to my user's control panel if the login was successful, or go to the login page if it's not? Ideally, I don't want to use a re-direct. Do I need to use ajax? Thank you! Can someone help me to edit this code...? I already tried to modify the script in many ways, but it doesn't work, I deleted the lines from the password in the script and also deleted the html to fill the password and do not work.. I dont really know wht to do.. I search online for a script, but i only find "user name and password" scripts, I just want a unlimited user name with no passwords... I dont need any type of security in the page, that is why I choose this script, but I dont need the password login.. .. This script is easy for me because it has HTML , I know there are other script on php, but are to complicated for me... I know this is very easy, but I dont know Java script, Im learning now.. NOTE: this page has "User name" and "password" to login or redirect to another page.. But I dont need the password option.. I just need the " user name"... I just want he visitor to Enter his/her "user name" and press login and the website will take him/her to a specific page for this user.. I want to have unlimited "user names" with NO passwords.... Can SOMEONE HELP ME WITH THIS... ====================== Here is the code to edit: =============================== <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <SCRIPT LANGUAGE="JavaScript"> <!-- The JavaScript Source --> <!-- Begin function Login(){ var done=0; var username=document.login.username.value; username=username.toLowerCase(); var password=document.login.password.value; password=password.toLowerCase(); if (username=="member1" && password=="password1") { window.location="page1.html"; done=1; } if (username=="member2" && password=="password2") { window.location="page2.html"; done=1; } if (username=="member3" && password=="password3") { window.location="page3.html"; done=1; } if (done==0) { alert("Invalid login!"); } } // End --> </SCRIPT> </head> <body> <center> <form name=login> <table width=225 border=0 cellpadding=0> <tr><td colspan=2><center><font size="+2"><b>Members-Only Area!</b></font></center></td></tr> <tr><td>Username:</td><td><input type=text name=username></td></tr> <tr><td>Password:</td><td><input type=text name=password></td></tr> <tr><td colspan=2 align=center><input type=button value="Login!" onClick="Login()"></td></tr> </table> </form> <p> </p> </center> <p> <p> </body> </html> I'm having trouble getting two password boxes to work on the same page, which I created using the JavaScript Kit Encrypted Password Generator (http://www.javascriptkit.com/epassword/index.htm). I've used the code that this generator produces, with some modifications as given by cheesebagpipe (http://www.codingforums.com/showthread.php?t=14646). These changes enable the user to press the keyboard's enter key to submit the password (as an alternative to clicking the submit button), and will also refocus the text box and select the text in it if the user enters the wrong password. The code works fine on pages with just one box (e.g. http://www.mistymusic.co.uk/StLuke's.html), but what changes are needed to make two work on the same page? (I'm new to web design and clueless when it comes to JavaScript, which I know isn't the most secure method of password protection, but will do for now). At the moment, on pages with two boxes (e.g. http://www.mistymusic.co.uk/BEAP.html), neither of the boxes work; this appears in the address bar instead: 'http://www.mistymusic.co.uk/BEAP.html?password2=help!' ('help!'=whatever has been entered in the text box). The full code for both boxes is given below. Code: <div id="passwordBoxes"> <div id="password2"> <form name="password1" onsubmit="submitentry();return false;"> <span class="WhiteLogin">Keyboard classes login</span> <input name="password2" type="password" class="AlignedFormBoxes" size="15" /> <input type="button" class="AlignedFormBoxes" value="Login" /> </form> </div> <div id="password1"> <form name="password1" onsubmit="submitentry();return false;"> <span class="WhiteLogin">Community Youth Choir login</span> <input name="password2" type="password" class="AlignedFormBoxes" size="15" /> <input type="button" class="AlignedFormBoxes" value="Login" /> </form> </div> </div> <script> var pass=new Array() var t3="" var lim=6 pass[0]="gc3Gu5uygvU8VDA" pass[1]="aNL6yjrU5AAKyy3" pass[2]="enSaX8glavp54H" pass[3]="WF3XUKEpbbMEx" pass[4]="8Pv7bsEqaIjNdb6b" pass[5]="35Pv7bsEqaIjNdb6" //configure extension to reflect the extension type of the target web page (ie: .htm or .html) var extension=".html" var enablelocking=0 var numletter="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" var temp3='' var cur=0 function max(which){ return (pass[Math.ceil(which)+(3&15)].substring(0,1)) } function testit(input){ temp=numletter.indexOf(input) var temp2=temp^parseInt(pass[phase1-1+(1|3)].substring(0,2)) temp2=numletter.substring(temp2,temp2+1) return (temp2) } function submitentry(){ t3='' verification=document.password1.password2.value phase1=Math.ceil(Math.random())-6+(2<<2) var indicate=true for (i=(1&2);i<window.max(Math.LOG10E);i++) t3+=testit(verification.charAt(i)) for (i=(1&2);i<lim;i++){ if (t3.charAt(i)!=pass[phase1+Math.round(Math.sin(Math.PI/2)-1)].charAt(i)) indicate=false } if (verification.length!=window.max(Math.LOG10E)) indicate=false if (indicate) window.location=verification+extension; else { alert("That wasn't the correct password. Please check that your CAPS Lock key is turned off and try again."); document.password1.password2.focus(); document.password1.password2.select(); } } </script> <script> var pass=new Array() var t3="" var lim=7 pass[0]="Qmsn8tUQZX4T0PC" pass[1]="DUtntGtFhaTppWO" pass[2]="JahI7L4JqbxZrwS" pass[3]="ong1qqnbr9rvV2s" pass[4]="7BlqC2sc8hQ8bWMK" pass[5]="15BlqC2sc8hQ8bWM" //configure extension to reflect the extension type of the target web page (ie: .htm or .html) var extension=".html" var enablelocking=0 var numletter="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" var temp3='' var cur=0 function max(which){ return (pass[Math.ceil(which)+(3&15)].substring(0,1)) } function testit(input){ temp=numletter.indexOf(input) var temp2=temp^parseInt(pass[phase1-1+(1|3)].substring(0,2)) temp2=numletter.substring(temp2,temp2+1) return (temp2) } function submitentry(){ t3='' verification=document.password1.password2.value phase1=Math.ceil(Math.random())-6+(2<<2) var indicate=true for (i=(1&2);i<window.max(Math.LOG10E);i++) t3+=testit(verification.charAt(i)) for (i=(1&2);i<lim;i++){ if (t3.charAt(i)!=pass[phase1+Math.round(Math.sin(Math.PI/2)-1)].charAt(i)) indicate=false } if (verification.length!=window.max(Math.LOG10E)) indicate=false if (indicate) window.location=verification+extension; else { alert("That wasn't the correct password. Please check that your CAPS Lock key is turned off and try again."); document.password1.password2.focus(); document.password1.password2.select(); } } </script> Any help would be a lifesaver - thanks in advance! Hi, I know nothing about javascript but I was able to handle the instructions to install the login/password featu http://www.javascriptkit.com/script/...ginpass2.shtml works great! however, when someone views the source code, they're able to see what the password is. additionally they can see the url of the page it would take them if they entered the password. how do i protect against this vulnerability? thanks in advance! I have an older website consisting of frames (html). Now I want to password protect one page. So far I added the following Javascript which I found on youtube: <SCRIPT> function passWord() { var testV = 1; var pass1 = prompt('Please Enter Your Password',' '); while (testV < 3) { if (!pass1) history.go(-1); if (pass1.toLowerCase() == "letmein") { alert('You Got it Right!'); window.open('protectpage.html'); break; } testV+=1; var pass1 = prompt('Access Denied - Password Incorrect, Please Try Again.','Password'); } if (pass1.toLowerCase()!="password" & testV ==3) history.go(-1); return " "; } </SCRIPT> <CENTER> <FORM> <input type="button" value="Enter Protected Area" onClick="passWord()"> </FORM> </CENTER> This works but the protected page opens in a new window not in the main frame. What do I have to add and where? Will search engines pick up this page and display it on the public? Thank you. CT my password target opens in a new window using the 'open.window' command but i would like a command string that opens this target in the same frame within my frames page that my other pages open in. thanks in advance manj Hi coders, I have a login form which has the following code: Code: <p> Username:<span><input type="text" id="uid" name="uid" size="14"/> </span> Pass:<span><input type="password" id="pwd" name="pwd" size="14"/></span> <a onclick="return loginload()" href="#" class="btn">Enter</a> Here is the loginload script directs me to the following page upon Enter: Code: function loginload() { window.location="step1.asp"; } Now that step1.asp gets the user & pass variables and pass them to step2.asp page that way: Code: <html> <!-- #include file="include/common.asp" --> <!-- #include file="include/security.asp" --> <head> <meta http-equiv="Content-Language" content="tr"> <meta name="GENERATOR" content="Microsoft FrontPage 12.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1254"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> <title>Login</title> </head> <body background="webimages/BGS/Gray.jpg" bgcolor="#D6D6DE" topmargin="2" leftmargin="35" oncontextmenu='return false' ondragstart='return false' onselectstart='return false'> <form name="frm1" method="post" action="step2.asp"> <input type="hidden" name="_uid" id="_uid"> <input type="hidden" name="_pwd" id="_pwd"> </form> <SCRIPT> document.forms[0]._uid.value = document.getElementById("uid").value; document.forms[0]._pwd.value = document.getElementById("pwd").value; document.forms[0].submit(); </script> </body> </html> After clicking on Enter on the login page, I receive the error for the step1.asp page: Line:20 Char:1 Object Required Code:0 Url=step1.asp Line 20 is the beginning of the script. Could not figure it out. Any opinions/advise are wellcome. How would you make a password feild and a retype password feild and they have to be the same?
Hello there guys! Thanks for taking time to view this thread. It's appriciated! I found a really nice menu (Javascript, JQuery) im not so high tech on this myself, and not the best coder either but whenever I use this menu it gives the login box on the website an error, it doesn't let people login.. I've tried to localize the error myself, but I just dont know how to fix it, I think the issue is that the site system i use doesn't support these type of scripts which gives the login errors! I'm currently using a free website system, which allows you to customize anything you want called "uCoz" The menu i used was: http://www.dynamicdrive.com/dynamici...enu-glossy.htm And I think it's the jquery that gives the login box errors.. I'm thankfull for answers if anyone knows Hello everyone. I have a a html page that is used as a login page. I know it is not secure but this is just for learning purposes, I'm not using it for anything important. My problem is that when I put in the correct login all that happens is the page just clears the text boxes as if you were starting over. I am trying to get it to go to register.html which is located in the same directory as the login page. Help with what I'm doing wrong would be greatly appreciated. Here is the code: Code: <html> <head> <title>Login Page</title> </head> <body> <script type = "text/javascript"> var count = 2; function validate() { var un = document.myform.username.value; var pw = document.myform.pword.value; var valid = false; var unArray = ["Philip", "George", "Sarah", "Michael"]; // as many as you like - no comma after final entry var pwArray = ["Password1", "Password2", "Password3", "Password4"]; // the corresponding passwords; for (var i=0; i <unArray.length; i++) { if ((un == unArray[i]) && (pw == pwArray[i])) { valid = true; break; } } if (valid) { alert ("Login was successful"); window.location = "register.html"; return false; } var t = " tries"; if (count == 1) {t = " try"} if (count >= 1) { alert ("Invalid username and/or password. You have " + count + t + " left."); document.myform.username.value = ""; document.myform.pword.value = ""; setTimeout("document.myform.username.focus()", 25); setTimeout("document.myform.username.select()", 25); count --; } else { alert ("Still incorrect! You have no more tries left!"); document.myform.username.value = "No more tries allowed!"; document.myform.pword.value = ""; document.myform.username.disabled = true; document.myform.pword.disabled = true; return false; } } </script> <form> <table border ="5"> <tr> <th colspan="2">Login</th> </tr> <tr> <td>Username:</td> <td><input type="text" name="username" /></td> </tr> <tr> <td>Password:</td> <td><input type="password" name="pword" /></td> </tr> <tr> <th colspan="2"><input type="Submit" value="Login" name="Submit" onClick="validate()" /><input type="Reset" value="Reset" /></th> </tr> </table> <p> <a href="register.html">New users click here to register</a> </p> </form></body></html> I am struggling trying to get this bit of code I've written to work. It should validate a password that is 10 characters long, starts with a D and includes 1 *. Even if I blank out two of the while statements and only use the charAt while statement it still fails to loop back. Any ideas? function validatePassword() { //declare and initialise variables var intCount = 0; var intCharCount = 7; var intAstrixCount =0; var strPassword = parseInt(prompt("Please enter password", "")); while (strPassword.length < intCount) { alert ("Your password must be at least 10 characters long"); strPassword = parseInt(prompt("Please enter password", "")); intCount++; } while (strPassword.charAt(0) != "a") { alert ("Your password does not start with a D"); strPassword = parseInt(prompt("Please enter password", "")); intCount++; } while (intAstrixCount != 1) { alert ("Your password does not contain an *"); strPassword = parseInt(prompt("Please enter password", "")); intCount++; } alert ("Your password is correct"); } Hello! I'm doing an assignment that validates a password field, the password field should only contain numbers, however this code only verifies the first number input in the field, which means i need to check through every singel input in the field, so i got a little problem <script> function checkPassword(strng) { var text = strng.value; var regel = text.replace(/[\(\)\.\-\ ]/g, ''); if(isNaN(parseInt(text))) { window.alert("Fel, password is not a number:" + text); } } else { window.alert("correct e-mail and password!"); } } </script> I've been thinking about a for loop should fix the problem, but im new to javascript, some help would be appreciated! I have a password check on my join form but it looks ugly the idea is good but it is all unaligned and makes the form look bad. I was wondering if you guys can help me format it i tried my self but it just caused it to not work at all lol. Right now it looks like this: ---------------------------- | -------- bar color -------- | ---------------------------- GOOD PASSWORD What i want is it to appear like this: __________________________ | -------- Good Pass -------- | <- Color in the bg,words in the box! Code: (function(A){A.extend(A.fn,{pstrength:function(B){var B=A.extend({verdects:["Very weak","Weak","Medium","Strong","Very strong"],colors:["#f00","#c06","#f60","#3c0","#3f0"],scores:[10,15,30,40],common:["password","sex","god","123456","123","cute","gamer","qwerty","monkey", "apple"],minchar:6},B);return this.each(function(){var C=A(this).attr("id");A(this).after("");A(this).after("<div class=\"pstrength-info\" id=\""+C+"_text\"></div>");A(this).after("<div class=\"pstrength-bar\" id=\""+C+"_bar\" style=\"margin-top: 5px; border: 1px solid gray; font-size: 1px; height: 15px; width: 260px;\"></div>");A(this).keyup(function(){A.fn.runPassword(A(this).val(),C,B)})})},runPassword:function(D,F,C){nPerc=A.fn.checkPassword(D,C);var B="#"+F+"_bar";var E="#"+F+"_text";if(nPerc==-200){strColor="#000";strText="Unsafe password word!";A(B).css({width:"0%"})}else{if(nPerc<0&&nPerc>-199){strColor="#ccc";strText="Too short";A(B).css({width:"5%"})}else{if(nPerc<=C.scores[0]){strColor=C.colors[0];strText=C.verdects[0];A(B).css({width:"10%"})}else{if(nPerc>C.scores[0]&&nPerc<=C.scores[1]){strColor=C.colors[1];strText=C.verdects[1];A(B).css({width:"25%"})}else{if(nPerc>C.scores[1]&&nPerc<=C.scores[2]){strColor=C.colors[2];strText=C.verdects[2];A(B).css({width:"50%"})}else{if(nPerc>C.scores[2]&&nPerc<=C.scores[3]){strColor=C.colors[3];strText=C.verdects[3];A(B).css({width:"75%"})}else{strColor=C.colors[4];strText=C.verdects[4];A(B).css({width:"92%"})}}}}}}A(B).css({backgroundColor:strColor});A(E).html("<span style='color: "+strColor+";'>"+strText+"</span>")},checkPassword:function(C,B){var F=0;var E=B.verdects[0];if(C.length<B.minchar){F=(F-100)}else{if(C.length>=B.minchar&&C.length<=(B.minchar+2)){F=(F+6)}else{if(C.length>=(B.minchar+3)&&C.length<=(B.minchar+4)){F=(F+12)}else{if(C.length>=(B.minchar+5)){F=(F+18)}}}}if(C.match(/[a-z]/)){F=(F+1)}if(C.match(/[A-Z]/)){F=(F+5)}if(C.match(/\d+/)){F=(F+5)}if(C.match(/(.*[0-9].*[0-9].*[0-9])/)){F=(F+7)}if(C.match(/.[!,@,#,$,%,^,&,*,?,_,~]/)){F=(F+5)}if(C.match(/(.*[!,@,#,$,%,^,&,*,?,_,~].*[!,@,#,$,%,^,&,*,?,_,~])/)){F=(F+7)}if(C.match(/([a-z].*[A-Z])|([A-Z].*[a-z])/)){F=(F+2)}if(C.match(/([a-zA-Z])/)&&C.match(/([0-9])/)){F=(F+3)}if(C.match(/([a-zA-Z0-9].*[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~].*[a-zA-Z0-9])/)){F=(F+3)}for(var D=0;D<B.common.length;D++){if(C.toLowerCase()==B.common[D]){F=-200}}return F}})})(jQuery) Sorry about the code i know its cluttered lol. I know this is not very secure, but there is a problem with this and I am not sure how to go on. Code: <form> <input type="text" name="password"/> <input type="button" onclick="check()"/> </form> What is wrong with my javascript? Code: function check (){ if(password=="pass1"){ alert('Password is correct!') } } I want to be able to put up files and assign passwords to individuals so that they can access one of those files but not all. In other words person A enters password & is redirected to file A; person B enters password & is redirected to file B, etc. Anyone have an example or know where I can get an example of a script like this? I am not a programmer so the simplier the better. Thanks
I have a simple password protection setup on my site but the password is displayed when it is typed in is there a way to change it to a # or * when it is typed in
Hi there... actually i am working on a project "random password generator". What basically is to be done in this project is to generate user password for the username randomly he has provided. Then, this password is to be stored in a text file in the following manner UserName Password ABCD JU12H6 Sdjksj HJudfdsfd Now my problem is that every time I just try to generate a new password, either a new file is made or the heading is rewritten again and again or if I just try to change the variables true and false, then the username and password headings are not printed. Please help. If someone knows how to do this using if-else method then please tell me, how it can be done? The code is attached. Code: <html> <HEAD> <SCRIPT LANGUAGE="JavaScript"> function GetSelectedItem() { chosen = ""; for (i = 0; i <3; i++) { if (document.myform.opt[i].checked) { chosen = document.myform.opt[i].value; } } if (chosen == "") { alert("Choose your password type") exit; } return chosen; } function getPassword(usnm,length,opti) { if(usnm=="") { alert("Enter user name"); exit; } var optsel=GetSelectedItem(); var num = "0123456789"; var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; var alphanum = "0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var pass = ""; if(length!=5 && length!=6 && length!=7 && length!=8 && length!=9 && length!=10) { alert("Enter password length between 5 and 10"); exit; } else { if (optsel==1) { for(x=0;x<length;x++) { i = Math.floor(Math.random() * 72); pass += alphanum.charAt(i); } } else if (optsel==2) { for(x=0;x<length;x++) { i = Math.floor(Math.random() * 10); pass += num.charAt(i); } } else if (optsel==3) { for(x=0;x<length;x++) { i = Math.floor(Math.random() * 52); pass += alpha.charAt(i); } } WriteToFile(usnm,pass); return pass; } } function WriteToFile(usnm,pass) { try { var fso1=new ActiveXObject("Scripting.FileSystemObject"); var pf1=fso1.OpenTextFile("Password.text",8); //if(pf=='false') //var fso=new ActiveXObject("Scripting.FileSystemObject"); //dspf=fso.OpenTextFile("Password.txt",8,true); //pf.WriteLine("Username\t\tPassword"); pf1.WriteLine(usnm+'\t\t'+pass); pf1.Close(); } catch(err) { var fso=new ActiveXObject("Scripting.FileSystemObject"); pf=fso.CreateTextFile("Password.txt",8,false); pf.WriteLine("Username\t\tPassword") pf.WriteLine(usnm+'\t\t\t'+pass); pf.Close(); } // fso= null; /* else { //var fso = new ActiveXObject("Scripting.FileSystemObject"); var s = fso.CreateTextFile("D:\\Password.txt", true); s.WriteLine('Username\t\tPassword'); //while(s.next()) s.WriteLine(usnm+'\t\t'+pass); s.Close(); }*/ /*var fso = new ActiveXObject("Scripting.FileSystemObject"); var s = fso.OpenTextFile("D:\\Password.txt",8, true); s.WriteLine('Username\t\tPassword'); //while(s.next()) s.WriteLine(usnm+'\t\t'+pass); s.Close();*/ } </script> </HEAD> <BODY> <center> <table width=80% border=0> <tr align=center> <td> <form name="myform"> <table border=0> <tr> <td> Enter Username: </td> <td> <input type=text name=userName value="" size=20> </td> </tr> <tr> <td> Chooose Password type:</td> <td> <input type="radio" name="opt" value="1" >Alphanumeric <input type="radio" name="opt" value="2">Numeric <input type="radio" name="opt" value="3">Alphabetic </td> </tr> <tr> <td> </tr> <tr> <td> Password length: </td> <td> <input type=text name=passwordLength value="" size=2> </td> </tr> </table> </td> </tr> <tr align=center> <td> New password: <input type=text name=password size=20> <br> <input type=button value="Generate password" onClick="document.myform.password.value = getPassword(document.myform.userName.value,document.myform.passwordLength.value, document.myform.opt.checked);"> </form> </td> </tr> </table> </center> </html> Hoping someone can help a simple soul!! I am trying to work out if there is a way that I can use a target url as a simple password (or even username) at a log in screen. Essentially I want to be able to send people to a different URL depending on their login details but without having to do anything too complicated or secure. Hoping someone can help Thanks in advance! OK, so I used this password protection.. http://www.javascriptkit.com/script/cut10.shtml But I need to use it more than once on a page.. and it doesn't work by just changing the password and file it points to... http://unaschade.com/portfolio.html So, is there any other part of the code I can change in order to use this script on the page more than once? Or does anyone have a better suggestion for me? Thanks in advance! I am fairly new to Javascript. From what I can compare to sample codes this should work. I have a button with an onclick that opens a prompt. Compares whats written to a php SESSION variable. If true redirects, if false displays an alert. However, all of this means nothing because when I press the button, no prompt comes up! Heres the code Code: <head> <script type="text/javascript"> function passPrompt() { var pass=prompt("Please enter your password:","") if pass = <?php $pwd ?> header('Location: setup.php'); else alert("Password is incorrect"); } </script> </head> ... <input id="settings" type="button" name="settings" value="Settings" onclick="passPrompt()" /> |