textarea 에 maxlength 적용하기

This commit is contained in:
gnuboard
2013-04-29 15:14:36 +09:00
parent 8b287ce841
commit 2f60a3860d
3 changed files with 13 additions and 3 deletions

View File

@ -36,7 +36,7 @@ function editor_html($id, $content, $ckeditor=true, $class="")
}
$ckeditor_class = $ckeditor ? "ckeditor" : "";
$html .= "\n<textarea id=\"$id\" name=\"$id\" class=\"$ckeditor_class $class\" style=\"width:100%;\">$content</textarea>";
$html .= "\n<textarea id=\"$id\" name=\"$id\" class=\"$ckeditor_class $class\" style=\"width:100%;\" maxlength=\"65536\">$content</textarea>";
$html .= "\n<span class=\"sound_only\">웹 에디터 끝</span>";
return $html;
}

View File

@ -117,9 +117,19 @@ var char_max = parseInt(<?php echo $comment_max ?>); // 최대
<th scope="row">내용</th>
<td>
<?php if ($comment_min || $comment_max) { ?><strong id="char_cnt"><span id="char_count"></span>글자</strong><?php } ?>
<textarea id="wr_content" name="wr_content" required class="required"
<textarea id="wr_content" name="wr_content" maxlength="10000" required class="required"
<?php if ($comment_min || $comment_max) { ?>onkeyup="check_byte('wr_content', 'char_count');"<?php } ?>><?php echo $c_wr_content; ?></textarea>
<?php if ($comment_min || $comment_max) { ?><script> check_byte('wr_content', 'char_count'); </script><?php } ?>
<script>
$("textarea#wr_content[maxlength]").live("keyup change", function() {
var str = $(this).val()
var mx = parseInt($(this).attr("maxlength"))
if (str.length > mx) {
$(this).val(str.substr(0, mx));
return false;
}
});
</script>
</td>
</tr>
</tbody>

View File

@ -118,7 +118,7 @@ var char_max = parseInt(<?php echo $comment_max ?>); // 최대
<th scope="row">내용</th>
<td>
<?php if ($comment_min || $comment_max) { ?><strong id="char_cnt"><span id="char_count"></span>글자</strong><?php } ?>
<textarea name="wr_content" id="wr_content" required class="required"
<textarea name="wr_content" id="wr_content" maxlength="10000" required class="required"
<?php if ($comment_min || $comment_max) { ?>onkeyup="check_byte('wr_content', 'char_count');"<?php } ?>><?php echo $c_wr_content; ?></textarea>
<?php if ($comment_min || $comment_max) { ?><script> check_byte('wr_content', 'char_count'); </script><?php } ?>
</td>