I am trying to implement a simple client side validation to ensure the user has logged on. Yes, I know I can’t rely upon client side validation, and will also implement albeit less elegant server side validation for non-javascript enabled users.
If the user hasn’t logged in (as determined by 1<>2 in my example), then I want an alert window to pop up and the link not to be followed. Can anyone comment how I should modify this script to do so. Thanks
[code=html]<head><script type=”text/javascript”>
function check_if_logged_on() {
if(1==2) //check if js session set
{return true;}
else
{alert(“Please Log In”); return false;}
}
</script></head>
<body>
<A HREF=”nextpage.php” onClick=”check_if_logged_on()”;>Link</a>
</body>
</html>