$("form").submit(function () {
2 var content = editor.getContentTxt();
3 var sum = 0;
4 re = /[u4E00-u9FA5]/g; //测试中文字符的正则
5 if (content) {
6 if (re.test(content)) //使用正则判断是否存在中文
7 {
8 if (content.match(re).length <= 10) { //返回中文的个数
9 $.dialog.tips("帖子正文不能小于10个汉字!");
10 return false;
11 }
12 else {
13 var $submit = $("input[type='submit']").attr("disabled", true);
14 setTimeout(function () { $submit.attr("disabled", false) }, 5000);
15 return true;
16 }
17 }
18 else {
19 $.dialog.tips("帖子正文不能小于10个汉字!");
20 return false;
21 }
22 }
23 else {
24 $.dialog.tips("帖子正文不能小于10个汉字!");
25 return false;
26 }
27 });
转载自:http://www.cnblogs.com/zhangpengnike/p/6053706.html