I have the following Code
$('#myform').submit(function() {
return false;
});
$('#insert').click(function() {
var value = $.trim($("#msg").val());
if (value.length < 0) {
alert("לא הכנסת הודעה !");
} else {
$.post(
$('#myform').attr('action'),
$('#myform :input').serializeArray(),
function(result) {
document.getElementById('msg').value = "";
$('#result').html(result);
}
);
}
});
<form method="post" action="insertmsg.php" id="myform">
<table>
<tr>
<td width="100%">
<textarea class="form-control" placeholder="ההודעה שלך" name="msg" id="msg"></textarea>
</td>
<td>
<button id='insert' class="form-control">שלח</button>
</td>
</tr>
</table>
<p id='result'></p>
</form>
I'm unable to check if the field is empty or not. I tried something but it doesn't work.
Any suggestions ?