the validation is working on the input fields, but it resists to do so on the textarea. Why? When i log the length of the textarea to the console, it says that document.guest is undefined... but in my opinion this is obviously not the case, because its working on the input fields.
<script type="text/javascript">
function fcheck() {
if (document.guest.name.value.length < 1) {
alert("Du musst einen Namen eingeben!");
return false;
}
if (document.guest.email.value.length < 1) {
alert("Du musst eine Email eingeben!");
return false;
}
if (document.guest.message.value.length < 1) {
alert("Du musst eine Nachricht eingeben!");
return false;
}
return true;
}
</script>
<div id="test2" class="col-md-6 form-group">
<form action="addcomment.php" method="post" name="guest" onSubmit="return fcheck();">
<div class="textform">
<p>Name:
<input type="text" name="name" class="form-control"/>
</p>
</div>
<div class="textform">
<p>E-Mail:
<input type="text" name="email" class="form-control"/>
</p>
</div>
<div class="textform">
<p>Nachricht(Maximal 300 Zeichen):</p>
<textarea cols="50" name="message" rows="10" class="form-control status-box" maxlength="300"> </textarea>
</div>
<br>
<div class="pull-left">
<p class="counter">300</p>
</div>
<div id="textarea" class="pull-right">
<input type="submit" value="Nachricht abschicken" class="btn btn-primary" />
</div>
</form>
</div>