PDA

View Full Version : Please help me!


drunkmafia
07-08-2011, 07:14 PM
<script type="text/javascript">
function MM_showHideLayers() { //v9.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3)
with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }
}
</script>
</head>
var count = 2;
function validate() {
var un = document.myform.username.value;
var pw = document.myform.pword.value;
var valid = false;

var unArray = ["Username's go here","and more","and more"];
var pwArray = ["Password go here","and more","and more"];

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 = "loggedin/new tab.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>
<div id="apDiv1">
<form name = "myform">
<p>Username:
<input type="text" name="username" />
</p>
<p>Password:
<input type="password" name="pword" />
</p>
<p>
<input type="button" value="Login" name="Submit" onclick= "validate()" />
</p>
</form>
OK here is the thing, this script it java script and therefore does not have a reg form and needs the user and pass info added in here

var unArray = ["Username's go here","and more","and more"];
var pwArray = ["Password go here","and more","and more"];
It all works but what I want is to have the ability to have a reg form because when I made this I did not need one but know I do, How can I do this but still in java script!

Corrosive
07-09-2011, 07:04 AM
You sure you wanna do reg in javascript? Seems like someone would only have to switch it off and bypass your security. Also easier to hack as it is client rather than server-side.