JavaScript - How To Modify Simple Password Script
I am using the simple password script from http://www.allwebco-templates.com/su...ect_simple.htm where the password is contained in the header script.
I need to change the password, e.g. from Jan to Feb to Mar to Apr etc. How could I modify the script to contain the list of passwords, and have it automatically utilise/apply the correct password for the current month? To a non-javascript person like me this seems like it should be simple..... Can anyone please suggest a solution? Thanks muchly in advance. Similar TutorialsI trying to modify that username password script so that only a password is needed,and if entered correctly, it takes you to a certain webpage but the script seems to break when I take out the username variables..is there any way I can do this? Heres the script, its from the resources on javascriptkit. How would I do this? Any help would be appreciated! Heres the script I found. <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 = "http://www.google.com"; 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 name = "myform"> <p>ENTER USER NAME <input type="text" name="username"> ENTER PASSWORD <input type="password" name="pword"> <input type="button" value="Check In" name="Submit" onclick= "validate()"> </p> </form> Hi I am a new user to JS, and I have a problem he I have some JS code to work on a data set with file name "data.txt" in the header section of an HTML page. Code: <script type="text/javascript" src="data.txt"></script> What I am trying to do is to ask a user to input a different file name, then update the file name in the <script> tag, for example, to Code: <script type="text/javascript" src="new_data.txt"></script> But I don't know how to update the file name. Any help will be appreciated. Hello, I am currently working on my school's website. The site is laid out with a DIV on the left set up as a menu (called "leftmenu") and a DIV to the right to display the content (called "maincontent"). Clicking a link in leftmenu calls a script which changes the content of "maincontent". The script currently works as it should except for one small error. The appropriate heading, text and image load for each link, but the formatting between the image and the paragraph is lost. When the page originally loads, the image is set to "float:left" and the paragraph wraps around it to the right. However, when the script runs and changes the contents, the paragraph no longer wraps around the image, but is written below it. Javascript function: Code: var nov12="News for November 12"; var nov11="News for November 11"; var nov10="News for November 10"; function writeNews(title,image,txt) { document.getElementById("newsTitle").innerHTML=title; document.getElementById("newsImage").src=image; document.getElementById("newsText").innerHTML=txt; } HTML for the links calling the function and maincontent: Code: <div class="leftmenu"> <h3>News</h3> <ul class="leftmenu"> <li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 12','img1.jpg',nov12)">Nov 12</a></li> <li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 11','img2.jpg',nov11)">Nov 11</a></li> <li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 10','img3.jpg',nov10)">Nov 10</a></li> </ul> </div> <div class="maincontent"> <h3 id="newsTitle">School News</h3> <img id="newsImage" class="newsimagestyle" src="img1.jpg" /> <p id="newsText"><img id="newsImage" class="newsimagestyle" src="" />Select the date from the menu on the left for news posted on that day.</p> </div> I have also attached the "before.jpg" and "after.jpg" screen captures from the relevant section of the website so you can see what changes are happening to the formatting. BEFO AFTER: Any help to keep the formatting in the same would be greatly appreciated. Thanks. Phil hi. in reference to this post: http://www.codingforums.com/showthread.php?t=226228 can some guru show me how to modify the matching columns script so that it works in html5? .. with a long center SECTION element and two shorter ASIDE elents .. 1 on each side. UPDATE .. Houston, we have an answer. 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()" /> On the 'Edit Profile' page of my eCommerce Wordpress Theme (http://www.projectdisobey.com/disobeyclothing), no error message appears when I do any of the following in the ''New Password' and 'Confirm New Password' text fields: 1. 'New Password' and 'Confirm New Password' do not match. 2. 'Confirm New Password' field is left empty. 3. New password is less than 5 characters. 4. New password is exactly the same as the current password. This is the script: Code: <script language="javascript" type="application/javascript"> function chk_form_pw() { if(document.getElementById('new_passwd').value == '') { alert("<?php _e(ENTER_NW_PW_JS_MSG) ?>"); document.getElementById('new_passwd').focus(); return false; } if(document.getElementById('new_passwd').value.length < 4 ) { alert("<?php _e(ENTER_NW_PW_MIN_JS_MSG) ?>"); document.getElementById('new_passwd').focus(); return false; } if(document.getElementById('cnew_passwd').value == '') { alert("<?php _e(ENTER_CONFIRMNW_PW_JS_MSG) ?>"); document.getElementById('cnew_passwd').focus(); return false; } if(document.getElementById('cnew_passwd').value.length < 4 ) { alert("<?php _e(ENTER_CONFIRMNW_PW_MIN_JS_MSG) ?>"); document.getElementById('cnew_passwd').focus(); return false; } if(document.getElementById('new_passwd').value != document.getElementById('cnew_passwd').value) { alert("<?php _e(ENTER_NW_AND_CONFIRM_PW_SAME_JS_MSG) ?>"); document.getElementById('cnew_passwd').focus(); return false; } } </script> I'd be extremely appreciative if anybody could help me fix the script so that it works as it is meant to. Javascript is not something I'm particularly familiar with... Thanks in advance! Let me first say I am not a java programmer but I can follow the tutorials and get some things to work. Here I am trying to create a password protected page, realizing the level of security is not very high. This page of code, link1.html, will be blank and if the correct password is entered then I want to automatically link to another page, barcs.html. I simply cannot find a way to do it.....Thanks Code: <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>Psw test link 1</title> <script language="JavaScript"> <!--hide var password; var pass1="cool"; var pass2="awesome"; var pass3="geekazoid"; password=prompt('Please enter your password to view this page!',' '); if (password==pass1 || password==pass2 || password==pass3) alert('Password Correct! Click OK to enter!'); else { window.location="http://www.acma-rc.com/"; } //--> </script> </head> <body> This is link1.html<br> </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! ok i am trying to make a countdown timer from 20 seconds when i click start where am i going wrong with this Code: <html> <head> </head> <body> <script type="text/javascript"> function timer() { var milisec=0 var seconds=20 document.counter.d2.value=20 function display() { if (milisec<=0){ milisec=9 seconds-=1 } if (seconds<=-1){ milisec=0 seconds+=1 } else milisec-=1 document.counter.d2.value=seconds+"."+milisec setTimeout("display()",100) display() }} </script> <form name="counter"> <center> Text Timer<br> <input type="text" size="30" name="d2"> <br> <input type="button" onclick="timer()" value="click me to start"> </center> </form> </body> </html> Hi, I need a very simple script that will do the following : I have a HTML form. I have an input call "title". Say I wrote "fleur-de-lys" I have a text area call "text" When I hit the submit button I want to do : 1. Create a HTML webpage with the name in input : fleur-de-lys.html 2. Add the text in "text" somewhere in the body of that new file fleur-de-lys.html 3. Add a preview of that text somewhere in my index page Basically it's like you post a new article on wordpress or whatever, but I just want something simple no database and just need help on how I do this. Thank you very much Hi all, I know this sounds absurd, but I like to display a clickable image in javascript. I have searched the net for like 2 hours, and I simply CANT find any page that can help me with that extremely simple javascript. This is how its look like in html: Code: <a href="http://www.horse.com"><img src="jul.jpg" width="468" height="80" border="0" /></a> Please! How can I make that simple code in javascript?! Thanks! Hey guys, so I am a designer (not a developer) doing a site for someone. I am playing with some simple free javascripts. I have lightbox and toggler. Both work great individually. They are conflicting and everywhere online says to set the both to onLoad in the body tag. Sounds easy enough. But I can't seem to figure out the call for this script: Code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="../js/expand.js"></script> <script type="text/javascript"> $(function() { $("h2.expand").toggler({method: "fadeToggle"}); }); //--><!]]> </script> <body onload="toggler();initLightbox()"> is what is seems like it should be for me. But that isn't working at all. Please help! I feel like I have tried every possible name with the toggler()... If you need more, I can point you to the site itself and you can see all of the (messy) code. Code: <script type="text/javascript"> function toggleVisibility4(controlId) { var z = document.forms["frm_sms"]["phone"].value; var minimumnum = 10; var control = document.getElementById(controlId); if (z.length <= minimumnum) { control.style.visibility = "visible"; } else { control.style.visibility = "hidden"; } </script> im not sure where im going wrong i am calling this script from a " onkeyup="toggleVisibility4('arrow')" " the arrow is a div i am wanting to hide when the input field "phone" on a form id of "frm_sms" has more than 10 characters any ideas guys I am a very novice web coder and can't get this to work... I've tried everything and am getting no where but frustrated! Thanks in advance!! Code: <html> <head> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin function calculateSavings() { var lastBill = eval(document.theForm.elements[0].value); var frequencyRating = eval(document.theForm.elements[1].value); var savingsRate = .05; var annualSavings = 0; /* if (frequencyRating == 'every day) { savingsRate = .01; } else if (frequencyRating == 'weekly) { savingsRate = .05; } else if (frequencyRating == 'monthly') { savingsRate = .15; } else if (frequencyRating == 'yearly') { savingsRate = .2; } */ annualSavings = lastBill * savingsRate; document.write(annualSavings); } // End --> </SCRIPT> </head> <body> <form name="savingsCalcForm"> How much was your last bill? <br><INPUT TYPE="text"> <br> <br> How often are you using your tractor? <br><input type="radio" name="group1" value="every day"> every day<br> <input type="radio" name="group1" value="weekly "> weekly<br> <input type="radio" name="group1" value="monthly"> monthly<br> <input type="radio" name="group1" value="yearly"> yearly<br> <br> <br> <INPUT TYPE="button" VALUE="calculate savings" onClick="calculateSavings();"> </form> </body> </html> Hey, so I have successfully used this tutorial; http://articles.sitepoint.com/articl...y-javascript/3 to create a web page that "smoothscrolls" down to a certain point of content on the page. So, I know the java works! My problem is, I have changed the website to be along the X axes and not the Y, so instead of it scrolling "down" the page, I would like it to scroll from left to right. i.e on the X axes not the Y. Is there anyway of doing this by editing that java file? All my buttons work and display the correct part of the website, but the java doesn't work slidiing sideways. Thank you in advance! Darren I'm in search for a simple and clean timed rotation script. I have these quotes, and right now they're coded so that a single quote displays and changes upon refresh. The script is really clean, and I would like to maintain the cleanliness but make the images rotate every couple of seconds. Here's the script... Code: <script type="text/javascript"> quote = new Array(3); quote[0] = "Quote 1"; quote[1] = "Quote 2"; quote[2] = "Quote 3"; index = Math.floor(Math.random() * quote.length); document.write(quote[index]); </script> It's probably a really simple piece of coding, but I'm still new to JavaScript, so it's obviously out of my range. I appreciate anyone who will help I'm using this script to show/hide a field if its corresponding radio button is pressed. It was working. I moved on to work on other things on the page, and it stopped. Pulled it off onto its on page, and still no go. Any thoughts? PHP Code: <script> $(document).ready(function() { $("div.desc").hide(); $("input[name$='hear']").click(function() { var test = $(this).val(); $("div.desc").hide(); $("#" + test).show(); $("div.desc").val(""); $("div.desc").attr("checked", false); }); }); </script> <table border=0><tr><td colspan="2" width=580><b>Please take a moment to help us with vital information for marketing purposes.<br /> Please be specific:</b></td></tr> <tr><td valign="top" colspan="2"><br>How did you hear about us?</td></tr> <tr><td width=195 valign=top> <div id="myRadioGroup"> <input type="radio" name="hear" value="dcranch" onfocus="this.className='reg_live';" onblur="this.className='reg_off';" > DC Ranch Community <br /> <input type="radio" name="hear" value="friend" onfocus="this.className='reg_live';" onblur="this.className='reg_off';" > From a friend <br /> <input type="radio" name="hear" value="counselor" onfocus="this.className='reg_live';" onblur="this.className='reg_off';" > Counselor Referral <br /> <input type="radio" name="hear" value="media" onfocus="this.className='reg_live';" onblur="this.className='reg_off';" > Media <br /> <input type="radio" name="hear" value="other" onfocus="this.className='reg_live';" onblur="this.className='reg_off';" > Counselor Referral <br /> </div> </td> <td valign=top> <div style="display: none;" id="dcranch" class="desc"> <input type="checkbox" value="Yes" name="resident" /> If so, are you a DC Ranch resident? )</div><br /> <div style="display: none;" id="friend" class="desc"> Name? <input type="text" name="how1" /></div><br /> <div style="display: none;" id="counselor" class="desc"> Name? <input type="text" name="how2" /></div><br /> <div style="display: none;" id="media" class="desc"> Source? <input type="text" name="how3" /></div><br /> <div style="display: none;" id="other" class="desc"> How? <input type="text" name="how4" /></div><br /> </td> </tr></table> Hi all, Did some searching but couldn't find anything to help me. I'm looking for a simple quiz script - basically, there would be an image on the screen (would be great if it was randomly generated out of maybe 100 different choices). The visitor would then click on one of two buttons (this is the "quiz" part) answering a question about the photo which was displayed. The script then tells the visitor if they got the answer right or wrong and then loads a new image for them to try again. It would be great if the script could keep a "streak counter" based on how many images a visitors got correct in a row. So for example: Question: is this a cat or a dog? [random image of dog or cat] [button to answer dog] [button to answer cat] Would this be fairly easy to implement (is there something like this already around) or is it more complicated than that? Thanks a bunch in advance for any help you can give. Having an unusual problem with the simple validation script below. In my script, I want to validate the username text field so that if the value of the text field (i.e. the amount of characters in the field) is less than 5, it would show a message in the page using innerHTML. The script works, but in a roundabout sort of way, or at least that's what it seems to me. Instead of making sure that the amount of characters in the text field is less than 5, it seems to disregard this entirely and instead make it so that if it has no value at all, the message will be shown. If it has a value of even 1 character, though, the message does not show. Not what I was trying to do, and I really don't know what's happened. Thanks in advance to anyone who can help out a newbie in need. Code: function uservalidate() { if (document.getElementById("user").value < 5) { document.getElementById("userdiv").innerHTML = "Username must be six characters or more." } else { document.getElementById("userdiv").innerHTML = "" } } Code: <body> <form id="form1"> <input type="text" id="user" onblur="uservalidate()" /> <div id="userdiv"></div> </form> </body> </html> I'm trying to built a simple Javascript page that will serve the purpose of merging the values inputted into a form, and then using concatenation to merge these values in with other text to form several lines of commands that would be entered into a router to perform some task. So in other words, it's just a "Merge" script. I should mention that I'm just starting to learn Javascript. I actually haven't been finding Javascript as easy as I thought it would be to learn, and I think it's because there are several ways to do the same thing and I wouldn't be surprised if my problem is I'm using two different methods here...or just using the completely wrong method.... I've seen examples of using 'for' loops and arrays in forms, and I still can't get my head around that. If possible for now I just wish to call in the values and concatenate them, but maybe I do need a loop I don't know Anyway, at this point, my only wish is to be able to get the script to concatenate the values, and then later I'll add the rest of the text it will merge in with and have it write to the page instead of the console. So here is what I have right now. It only partially works (I'm only writing to the console in FireFox at the moment to debug while I test, so that is why you see console.log instead of document.write or whatever. There are 4 fields in the form, and for example, if I enter in each field one word: This is a test The ONLY result I get when submitting the form is the word "This". Then the form is cleared out of all values that were entered. I'd like it to grab all the values at once but that isn't happening. Also, you'll notice I have some 'var' statements commented out. I was trying to use them so that I can later shortcut my script by concatenating using a shorter variable. (ie - using the variable 'cluster' instead of 'document.forms.myForm.cluster.value' when I'm writing the rest of the script). However something isn't right as no matter where I try putting the var statements I get errors that those variables are undefined. I even tried defining them at some point first with some random value but that didn't help either), so that's why I commented them out for now. anyway, here is my feeble attempt at writing this script, any help or guidance would be much appreciated. Code: <!DOCTYPE html PUBLIC "-//WC3//DTD XHTML 1.0 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Router Subnet Commands</title> </head> <body bgcolor="#FFFFFF"> <script language="Javascript" type="text/javascript"> //var cluster = document.forms.myForm.cluster.value; //var subnetip = document.forms.myForm.subnetip.value; //var routerip = document.forms.myForm.routerip.value; //var cidr = document.forms.myForm.cidr.value; function merge() { console.log(document.forms.myForm.cluster.value) + console.log(document.forms.myForm.subnet.value) + console.log(document.forms.myForm.router.value) + console.log(document.forms.myForm.cidr.value); } </script> <form id="myForm"> <input name="cluster" id="cluster"/> cluster number <p> <input name="subnetip" id="subnetip"/> subnet IP address <p> <input name="routerip" id="routerip"/> router IP address<p> <input name="cidr" id="cidr"/> CIDR <p> <input type="submit" value="Get Commands" onclick="merge()" /> </form> </body> </html> Any advice would be much appreciated. Thanks Nat |