i have a list in my HTML page with the following code.
<li><a href="HomePage.html">Home</a></li>
<li><a href="#" >Register</a></li>
<li><a href="#" onclick="loginCheck();">Contact Us</a></li>
<li><a href="MakePayment.aspx" onclick="loginCheck();">Services</a></li>
<li><a href="HomePage.html" onclick="logout();">Log Out</a></li>
my log in check function is as follows.
function validate()
{
some validations done here.if found true change the variable log in to true.
login = true;
}
function loginCheck() {
if (!login) {
alert("Log In to continue operations");
return false;
}
the page gives an alert Log In to continue operations. But still moves to the next page which was clicked. How can i stop this ?
false. You have to include thereturnstatement in the "onclick" attribute value.