$("#button").bind("click", function () { var messageLenght = $("#text").length(); if($('#text').val() != '' && messageLenght < 200 ){ var message = $("#text").val(); $.ajax({ url: "chatGetMsg.php", type: "POST", data: {message}, dataType: "json", complete: function () { show('send'); del(); } }); } }); Why does not it work
messageLenght < 200