78 lines
2.5 KiB
Plaintext
78 lines
2.5 KiB
Plaintext
|
|
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'new_user' %>
|
|
<script>
|
|
|
|
|
|
function check_and_submit(doc){
|
|
$("#error").html('').hide();
|
|
check_forum_name();
|
|
if(check_pass == false){
|
|
return;
|
|
}
|
|
if( $("textarea[name='forum[name]']").val().trim() == "" && $("textarea[name='forum[description]']").val().trim() != "" ){
|
|
$("#error").html("名称不能为空").show();
|
|
return;
|
|
} else if( $("textarea[name='forum[description]']").val().trim() == "" && $("textarea[name='forum[name]']").val().trim() != "" ){
|
|
$("#error").html("描述不能为空").show();
|
|
return;
|
|
}else if($("textarea[name='forum[description]']").val().trim() == "" && $("textarea[name='forum[name]']").val().trim() == ""){
|
|
$("#error").html("名称和描述不能为空").show();
|
|
return;
|
|
}
|
|
else{
|
|
doc.parent().parent().parent().submit();
|
|
}
|
|
}
|
|
var check_pass = true;
|
|
function check_forum_name(){
|
|
check_pass = true;
|
|
name = $("textarea[name='forum[name]']").val().trim();
|
|
if( name != ""){
|
|
$.get(
|
|
'<%= check_forum_name_forums_path %>',
|
|
{"forum_name":name,"forum_id":<%= @forum.id%>},
|
|
function(data){
|
|
|
|
if( data == 'true'){
|
|
$("#error").html("贴吧名称已经存在").show();
|
|
check_pass = false;
|
|
}
|
|
}
|
|
);
|
|
}else{
|
|
check_pass = false;
|
|
}
|
|
}
|
|
</script>
|
|
<%= render 'form_edit_mode' %>
|
|
<script>
|
|
var textarea = document.getElementById('forum_name');
|
|
autoTextarea(textarea);
|
|
var textarea1 = document.getElementById('forum_desc');
|
|
autoTextarea(textarea1);
|
|
$(function(){
|
|
$('#forum_name').keypress(function(e)
|
|
{
|
|
var n = 0;
|
|
var str = this.value;
|
|
for (i = 0; i < str.length; i++) {
|
|
var leg = str.charCodeAt(i);//ASCII码
|
|
if (leg > 255) {
|
|
n += 2;
|
|
} else {
|
|
n += 1;
|
|
}
|
|
}
|
|
if(n >= 160 && e.keyCode != 8)
|
|
if(document.all)
|
|
{
|
|
e.returnValue = false;
|
|
}
|
|
else
|
|
{
|
|
e.preventDefault();
|
|
}
|
|
|
|
})
|
|
})
|
|
</script> |