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

Why is my paragraph not being invisible with this code?

Status
Not open for further replies.

newtomysql

Technical User
Apr 11, 2001
96
MY
Dear All,
I got a very simple code to invisible and visible a paragraph. I am using javascript to do it but is just not working.
<script type="text/javascript">
function checkForm(this)
{
//alert("ok");
var myElement = document.getElementById("error_1");

myElement.style.visibility="visible";
}
</script>

so upon submit I call the above function
This is how I set my parapgraph within my form. When I call the function the alert ok works meaning that it calls the function right?
<p class="error" id="layer1" style="display: none" >
<small>Username Cannot Be Empty</small>
</p>
What is going wrong? Thanks.

 
Dear feherke,
I have changed my code now to this
<p class="error" id="error_1" style="visibility:hidden" >
<small>Username Cannot Be Empty</small>
</p>
I have change the style="display: none" to style="visibility:hidden".

<script type="text/javascript">
function checkForm(form)
{
//alert("ok");
var myElement = document.getElementById("error_1");
myElement.style.visibility="visible";
}
</script>

Now when I submit my form the paragraph appear just like a blink and then is no more ready. What I want upon submit it to appear and not just blink.
 
Hi

Then stop the submitting. Return [tt]false[/tt] from the event handler.
Code:
<form onsubmit="checkForm(this)[red]; return false[/red]">

[gray]# or[/gray]

<form onsubmit="[red]return[/red] checkForm(this)">
[gray]# and make sure the checkForm() function returns false when the browser should not submit the form[/gray]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top