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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP! Trying use Javascript Hidden / Visible

Status
Not open for further replies.

victory92

Programmer
Sep 18, 2002
35
US
Hi everyone...

I'm a rookie volunteering for a charity. I'm trying to have a password checking program that will validate the password before continuing

I'm trying to have a message appear on the screen if an invalid password is entered. - by using hidden/visibility.

I've created a gif saying "Invalid Password" so that there is not a textbox on the screen as the users are not savvy at all. However this gif always shows.

Here's a scaled pgm to illustrate what I'm trying to do..

Any help is greatly appreciated as I have no other people who are programmer types. I've tried multiple versions of this ... to no avail

I've rename our organization to - so don't be alarmed if you don't see the gif. I'm just trying to find how to use hidden visible and despite many, many google searches - I can't get this to work.

Thank you!!!!!!!!!!!!!1

Cyberter


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>xxx</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


<link rel="stylesheet" type="text/css">
</head>

<script language="Javascript">
<!--
function NoError() {
document.getElementById(ShowErr).style.visibility="hidden";
}
function ShowError() {
document.getElementById(ShowErr).style.visibility="visible";
}

//=============================================================================
function Pwd3() {
//=============================================================================

errMsg2 = false
errTxt2 = ""

var u = "Password1";
var b = "Password2";

var z=false;

//This is for testing
// this is for testing
alert(document.PwdForm3.Pwd.value);

if ((document.PwdForm3.Pwd.value==u) || (document.PwdForm3.Pwd.value==b)) {
z=true
}


if ((z==false)) {
// document.getElementById(thepic).style.visibility = "visible";
ShowErr.style.visibility="visible";
return false;
}

}
//-->
</script>

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="NoError()" >


<form method="POST" onSubmit="return Pwd3()" name="PwdForm3" action=" >

<b><font face="Arial">Please enter the password to access this webpage&nbsp;</font></b>

<span style="background-color: #cccccc">
<input type="password" name="Pwd" size="20">
</span>

<input type="submit" value="Submit" name="B1">
<input type="reset" value="Reset" name="B2"></p>
<input type=hidden name="redirect" value="
<span ID="ShowErr">
<img border="0" src=" width="299" height="22">
</span>



</form>

</body>
</html>
 
Hi

Code:
[gray]// line 15[/gray]
document.getElementById([red]'[/red]ShowErr[red]'[/red]).style.visibility="hidden";

[gray]// line 18[/gray]
document.getElementById([red]'[/red]ShowErr[red]'[/red]).style.visibility="visible";

[gray]// line 44[/gray]
[red]document.getElementById('[/red]ShowErr[red]')[/red].style.visibility="visible";

Feherke.
 
Maybe using quotes in the element name

Code:
<script language="Javascript">
<!--
function NoError() {
    document.getElementById('ShowErr').style.visibility="hidden"; 
}
function ShowError() {
    document.getElementById('ShowErr').style.visibility="visible"; 
}

Cheers,
Dian
 
I tried putting single quotes - and I'm still getting errors.

Line 16
char 5
Error Object required
File file:///C:/Users/Therese/AppData/Local/Temp/FrontPageTempDir/pvw5.htm


I also get an error when i put the following code in...

function NoError() {
var a1="ShowErr";
document.getElementById(a1).style.visibility="hidden";
}
function ShowError() {
var a2="ShowErr";
document.getElementById(a2).style.visibility="visible";
}


Any other suggestions???


 
One point to note: While your users may not be tech savvy enough to view the page source to see the password, there are plenty of people who are.

This means if someone finds your website, all they will need to do is view the source to the page to get the password, and could potentially cause untold mayhem (although you've not said what is behind the password, chances are it's something you wanted secured, otherwise you wouldn't have a password, right?)

So my suggestion is do this properly, and do it server-side, or leave yourself wide open to any malicious intent.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top