ive got a small problem.. i hope u can help me..
ive got a customn comment system and all is just working fine when submitting a post..
but when i want to accept '0' as comment a blank comment gets submitted..
my code would be:
Code: Select all
$("#commentform").submit(function(event) {
event.preventDefault();
var $form = $(this), $text = $form.find('textarea[name="comment_text"]').val();
alert($text);
if ($text != "") {
$.ajax({
type: "POST",
url: "clubs_ajax.php",
data: {
cid: getParameter(window.location.search.substring(1), "cid"),
mode: "post_comment",
comment_text: $text
}}).done(function() {
$form.find('textarea[name="comment_text"]').val("");
$("#comment_sec").load(location.href + " #comment_sec > *");
alert("{LA_CLUB_COMMENT_POSTED}");
});
}
else {
alert("{LA_CLUB_BLANK_COMMENT}");
}
});
and it seems to be allright..
Code: Select all
case 'post_comment':
$cid = request_var('cid', 0);
$comment_text = request_var('comment_text','', true);
if ($comment_text != '')
{
$message_parser = new parse_message();
$message_parser->message = utf8_normalize_nfc($comment_text);
if ($message_parser->message)
{
$message_parser->parse(true, true, true, true, false, true, true, true);
}
$sql_ary = array(
'club_id' => $cid,
'user_id' => (int) $user->data['user_id'],
'comment_time' => time(),
'comment_text' => $message_parser->message,
'comment_uid' => $message_parser->bbcode_uid,
'comment_bitfield' => $message_parser->bbcode_bitfield,
);
$sql = 'INSERT INTO ' . CLUBS_COMMENT_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
$sql = 'SELECT MAX(comment_id) as m_comment_id FROM ' . CLUBS_COMMENT_TABLE;
$result = $db->sql_query($sql);
$coid = $db->sql_fetchfield('m_comment_id');
$db->sql_freeresult($result);
$comments_info = $bc->get_comment_info($coid);
$c_sql_ary = array(
'club_comments' => (int) $comments_info['club_comments'] + 1,
);
$sql = 'UPDATE ' . CLUBS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $c_sql_ary) . ' WHERE club_id = ' . (int) $comments_info['club_id'];
$db->sql_query($sql);
}
break;
thx woipi