mck9235
01-04-2005, 11:20 PM
Okay what I am going to show you is a trick that helps add a little more security to JS. If you want a simple password protection this is for you.
<HTML>
<HEAD>
<p></p>
<form name="myform" method="post"
action="">
<p><span id="p">Enter Password [6 max]</span><br>
<INPUT name="pwd1" type="password" maxlength="6" size="20">
</form>
<input type="button" value="Validate"
onclick="validate()"/>
</p>
<script LANGUAGE = JavaScript>
function validate()
{
var entry = document.forms.myform.pwd1.value.toLowerCase();
if( entry == "yahoo") window.location = "http://www.fandango.com";
else
{
window.alert("Password Incorrect: Please retry");
document.forms.myform.pwd1.value = "";
}
}
</SCRIPT>
</HEAD>
</BODY>
</HTML>
Okay you see the password is yahoo. To add a bit more security save, and upload this file call it something like shoutbox.js etc. Make it funny, as if you named it password, anyone with a bit of knowledge could get to it.
Note: This is not extrmee security it is just better than having it all there in the source.
Next in the docuemnt you wish to have the script put this in:
<script LANGUAGE='Javascript' SRC='shoutbox.js'>
That will get the file, you could .htacess that file if you want.
<HTML>
<HEAD>
<p></p>
<form name="myform" method="post"
action="">
<p><span id="p">Enter Password [6 max]</span><br>
<INPUT name="pwd1" type="password" maxlength="6" size="20">
</form>
<input type="button" value="Validate"
onclick="validate()"/>
</p>
<script LANGUAGE = JavaScript>
function validate()
{
var entry = document.forms.myform.pwd1.value.toLowerCase();
if( entry == "yahoo") window.location = "http://www.fandango.com";
else
{
window.alert("Password Incorrect: Please retry");
document.forms.myform.pwd1.value = "";
}
}
</SCRIPT>
</HEAD>
</BODY>
</HTML>
Okay you see the password is yahoo. To add a bit more security save, and upload this file call it something like shoutbox.js etc. Make it funny, as if you named it password, anyone with a bit of knowledge could get to it.
Note: This is not extrmee security it is just better than having it all there in the source.
Next in the docuemnt you wish to have the script put this in:
<script LANGUAGE='Javascript' SRC='shoutbox.js'>
That will get the file, you could .htacess that file if you want.