There should be an easy way of validating this textarea without the use of a plug-in, been trying to check if textarea is empty or has an empty value but I just could not make this work. I have a http://jsfiddle.net/creativestudio/f3qQ5/
Hope someone could help.
This is my html:
<div class="post-container">
<form class="reply-form">
<div class="reply-box">
<textarea placeholder="Reply box 1..." columns="10" rows="1" name="comment-input"></textarea>
<input type="submit" value="Send">
</div>
<div class="post-dropdown"></div>
<div class="post-dropdown-content">
<div class="post-dropdown-reply">1</div>
</div>
</form>
</div>
<div class="post-container">
<form class="reply-form">
<div class="reply-box">
<textarea placeholder="Reply box 2..." columns="10" rows="1" name="comment-input"></textarea>
<input type="submit" value="Send">
</div>
<div class="post-dropdown"></div>
<div class="post-dropdown-content">
<div class="post-dropdown-reply hidden">1</div>
</div>
</form>
</div>
This is my Js:
function gettingReplyVal() {
$('.reply-form').submit(function(e) {
var textAreaValue = $(this).find('textarea').val();
post = $("<div>").addClass("post-dropdown-reply");
post.html(textAreaValue);
$(this).find('.post-dropdown-content').prepend(post);
e.preventDefault();
$('textarea').val('');
});
}
gettingReplyVal();
You can just use .val(), but I added the trim() just to compensate for spaces.