I am having some trouble with the self.location.replace() function. It will not load a page when I use the submit button to check a text and password field.
This is my generic code. I have the onSubmit pass the whole of the form data into the function, and I sort it from there. The names of the fields should be self evident.
function SubCheck(FormData)
{
if(FormData.UName.value!="")
{
if(FormData.Pass.value!="")
{
if(FormData.UName.value!="User1" || FormData.UName.value!="User2")
{
window.location.replace("NotReg.htm")
return true
}
else
{
if(FormData.UName.value="User1")
{
if(FormData.Pass.value="A_Password")
{
self.location.replace("Logged.htm")
return true
}
else
{
self.location.replace("NotLogged.htm")
return true
}
}
else if(FormData.UName.value="User2")
{
if(FormData.Pass.value="A_Password")
{
this.location.replace("Logged.htm")
return true
}
else
{
self.location.replace("NotLogged.htm")
return true
}
}
}
}
else
{
alert("You must enter your password!")
return false
}
}
else
{
alert("You must enter a username!")
return false
}
}
If anyone can offer me some help, I would appreciate it very much. (I realize that the existance of the actuall name and password within the code makes for very poor security, but, it is on a personal server, that only I and a friend use, simply to test out our pages.)
This is my generic code. I have the onSubmit pass the whole of the form data into the function, and I sort it from there. The names of the fields should be self evident.
function SubCheck(FormData)
{
if(FormData.UName.value!="")
{
if(FormData.Pass.value!="")
{
if(FormData.UName.value!="User1" || FormData.UName.value!="User2")
{
window.location.replace("NotReg.htm")
return true
}
else
{
if(FormData.UName.value="User1")
{
if(FormData.Pass.value="A_Password")
{
self.location.replace("Logged.htm")
return true
}
else
{
self.location.replace("NotLogged.htm")
return true
}
}
else if(FormData.UName.value="User2")
{
if(FormData.Pass.value="A_Password")
{
this.location.replace("Logged.htm")
return true
}
else
{
self.location.replace("NotLogged.htm")
return true
}
}
}
}
else
{
alert("You must enter your password!")
return false
}
}
else
{
alert("You must enter a username!")
return false
}
}
If anyone can offer me some help, I would appreciate it very much. (I realize that the existance of the actuall name and password within the code makes for very poor security, but, it is on a personal server, that only I and a friend use, simply to test out our pages.)