Demo:
Hướng dẫn:
ACP >> Modules >> HTML & JAVASCRIPT >> Javascript codes management >> Create a new javascriptTitle * : Giới hạn ký tự tối thiểu
Placement: In all the pages (nếu muốn áp dụng cả khi gửi chủ đề) hoặc In the Topics (nếu muốn chỉ áp dụng ở quickreply)
Javascript Code * :
Code:
$(function () {
var min = 10,
a;
$("input[name='post']").click(function () {
a = $("#text_editor_textarea").sceditor("instance").val().replace(/\s|\[\/?(b|i|u|strike|list(=(1|a))?|\*|quote(=".+")?|hr|code|spoiler(=[^\[\]]*)?|hide|table|tr|td|img.+\/img|flash.+\/flash|youtube.+\/youtube|dailymotion.+\/dailymotion|size(=\d+)?|color(=#.{6})?|font(=[^\[\]]*)?|url(=[^\s\[\]]*)?|rand|flipv|fliph|blur|fade|wow|sub|sup|updown|scroll|justify|right|center|left)\]/gi, '').length;
if (min > a) return alert("Bài viết quá ngắn!\nSố ký tự tối thiểu là " + min + " ký tự.\nBạn cần viết thêm " + (min - a) + " ký tự nữa mới có thể gửi bài."), !1
})
});
Lưu ý:
Trong code trên, số 10 là số ký tự tối thiểu để thành viên có thể đăng bài viết. Bạn có thể thay đổi nó bằng số bạn muốn.Tags: #code #tuts