Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To all people who want a basic password protectian javascript.

Status
Not open for further replies.

Ghostrider

Programmer
May 3, 1999
4
AU
I finally found a script that i can work on my network and is perfect for javascripting the script is<br>
<br>
&lt;script language="javascript"&gt;<br>
&lt;!--//<br>
/*This Script allows people to enter by using a form that asks for a<br>
UserID and Password*/<br>
function pasuser(form) {<br>
if (form.id.value=="Staff") { <br>
if (form.pass.value=="openstaff") { <br>
location="stafflounge.html" <br>
} else {<br>
alert("Invalid Password")<br>
}<br>
} else { alert("Invalid UserID")<br>
}<br>
}<br>
//--&gt;<br>
&lt;/script&gt;<br>
<br>
&lt;center&gt;<br>
&lt;table bgcolor="white" cellpadding="12" border="1"&gt;<br>
&lt;tr&gt;&lt;td colspan="2"&gt;&lt;center&gt;&lt;h1&gt;&lt;i&gt;&lt;b&gt;Login<br>
Area&lt;/b&gt;&lt;/i&gt;&lt;/h1&gt;&lt;/center&gt;&lt;/td&gt;&lt;/tr&gt;<br>
&lt;tr&gt;&lt;td&gt;&lt;h1&gt;&lt;i&gt;&lt;b&gt;UserID:&lt;/b&gt;&lt;/i&gt;&lt;/h1&gt;&lt;/td&gt;&lt;td&gt;&lt;form name="login"&gt;&lt;input<br>
name="id" type="text"&gt;&lt;/td&gt;&lt;/tr&gt;<br>
&lt;tr&gt;&lt;td&gt;&lt;h1&gt;&lt;i&gt;&lt;b&gt;Password:&lt;/b&gt;&lt;/i&gt;&lt;/h1&gt;&lt;/td&gt;&lt;td&gt;&lt;input name="pass"<br>
type="password"&gt;&lt;/td&gt;&lt;/tr&gt;<br>
&lt;tr&gt;&lt;td&gt;&lt;center&gt;&lt;input type="button" value="Login"<br>
onClick="pasuser(this.form)"&gt;&lt;/center&gt;&lt;/td&gt;&lt;td&gt;&lt;center&gt;&lt;br&gt;&lt;input<br>
type="Reset"&gt;&lt;/form&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/center&gt; <br>
<br>
<br>
and i got it from this site this site has got scripts that work for everything.
 
If the user just views the source code of the page, doesn't s/he have access to the login and password?&nbsp;&nbsp;I guess it works to keep away pesky peekers that are just browsing.<br><br>-al4k28
 
Hmm same questoin, any client-side script is always fully exposed to the user, if you want actual security, I'd strongly recomend something like Server side script, CGI,ASP etc. Only thing is tho your webserver must allow you to use server side reasources. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML, ASP(somewhat), QBasic(least i didnt start with COBOL)
 
I agree with the two above - go with the server side.<br>--BUT--<br>if you must use a javascript pass protection, have the login page put the username, and the password in the searchstring of the location.<br><br>then, have the reciving page check the searchstring for a correct username, and password. And if it isn't right, alert, and redirect the user back to the login page. This is more effective. <br><br>I have written one of these scripts, for more information, e-mail me, as I have no notion of where it is at the moment. <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top