Simple Password Protection on DW page
Hi, I am trying to employ a simple password-only protection to some pages on a website I'm building. I've found what should be the appropriate code at this site: http://javascriptkit.com/script/cut10.shtml
Here is their sample code, password only with a simple popup window to enter the password:
<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>
The difference is that instead of the centered input = button their sample has on the javascriptkit.com page, I'd like the form to be launched from the click of my Log In button I have in my design – or from clicking on the links for the three pages named: 'membermeetings.htm', 'boardmemberscommittee.htm', 'news_n_photos.htm'. Am I missing a <Form> wrap?
I could also use some tips on where and how much code to put into my <body> section; all of it, part of it?
Here is the code I entered in by adding "Call JavaScript" in behaviors:
onclick="MM_callJS('(\'function passWord() { var testV = 1; var pass1 = prompt(\\\'Please Enter Your Password\\\',\\\' \\\'); while (testV < 3) { if (!pass1) history.go(-1); if (pass1.toLowerCase() == \\"community\\") { alert(\\\'Welcome!\\\'); window.open(\\\'membermeetings.html\\\',\\\'boardmemberscommittee.htm\\\',\\\'news_n_photos.htm\\\'); break; } testV+=1; var pass1 = prompt(\\\'Access Denied - Password Incorrect, Please Try Again.\\\',\\\'Password\\\'); } if (pass1.toLowerCase()!=\\"password\\" & testV ==3) history.go(-1); return \\" \\"; }
Thanks in advance for your help! Brent
