The following piece of javascript does work as I would expect in Netscape. What happens it that when you click check without typing anything it will display the message as expected but then if you type something and click then it still displays the message which it shouldn't. If you click again it is fine.
Any ideas?
Duncan
Any ideas?
Duncan
Code:
<html>
<head>
<title></title>
<script language="JavaScript">
<!--
function checkfortext() {
if (!TextAreaRequired('weaknesses','sform2','textfield')) {
alert("You must enter some weaknesses.");
return false;
}
//call to another function
}
function TextAreaRequired(Layer, Form, Field) {
if (navigator.appVersion.indexOf("MSIE") > 0) {
var length = eval("document."+ Form +"." + Field +".value.length");
} else {
var length = eval("document."+Layer+".document."+ Form +"." + Field +".value.length");
}
if (length == 0) {
return false;
} else {
return true;
}
}
//-->
</script>
</head>
<body>
<div id="weaknesses" style="position:absolute; left:291px; top:295px; width:218px; height:143px; z-index:7">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">Weaknesses</font></b>
<form name="sform2" method="post" action="">
<textarea name="textfield" cols="12" rows="5"></textarea>
<a href="#" onMouseDown="checkfortext()">Check</a>
</form>
</div>
</body>
</html>