Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
6857b62f00
|
@ -9,10 +9,10 @@
|
|||
<div id="error" style="display: none;color: red;">
|
||||
</div>
|
||||
<div>
|
||||
<textarea type="text" id="forum_name" name="forum[name]" class="postCreateInput" placeholder="对应贴吧名称" ><%= @forum.name.html_safe%></textarea>
|
||||
<textarea type="text" id="forum_name" name="forum[name]" maxlength="50" class="postCreateInput" placeholder="对应贴吧名称" ><%= @forum.name.html_safe%></textarea>
|
||||
</div>
|
||||
<div class="mt15">
|
||||
<textarea type="text" id="forum_desc" name="forum[description]" class="postCreateInput" placeholder="对应贴吧描述" ><%= @forum.description.html_safe%></textarea>
|
||||
<textarea type="text" id="forum_desc" name="forum[description]" maxlength="5000" class="postCreateInput" placeholder="对应贴吧描述" ><%= @forum.description.html_safe%></textarea>
|
||||
</div>
|
||||
<div class="mt10">
|
||||
<div class="fr"><a href="javascript:void(0);" class="submit_btn" onclick="check_and_submit($(this));">确定</a></div>
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
$('#forum_name').keypress(function(e)
|
||||
{
|
||||
var n = 0;
|
||||
var str = this.value;
|
||||
var str = this.val().trim();
|
||||
for (i = 0; i < str.length; i++) {
|
||||
var leg = str.charCodeAt(i);//ASCII码
|
||||
if (leg > 255) {
|
||||
|
|
|
@ -51,8 +51,9 @@
|
|||
});
|
||||
$('#forum_name').keypress( function(e)
|
||||
{
|
||||
alert(1)
|
||||
var n = 0;
|
||||
var str = this.value;
|
||||
var str = this.val().trim();
|
||||
for (i = 0; i < str.length; i++) {
|
||||
var leg = str.charCodeAt(i);//ASCII码
|
||||
if (leg > 255) {//大于255的都是中文
|
||||
|
@ -61,6 +62,7 @@
|
|||
n += 1;//英文,不多说了
|
||||
}
|
||||
}
|
||||
console.log(n)
|
||||
if(n >= 160 && e.keyCode != 8)
|
||||
if(document.all)
|
||||
{
|
||||
|
@ -136,14 +138,14 @@
|
|||
<div class="red fl mb10" id="error" style="display: none">error</div>
|
||||
<%= form_tag({:controller => 'forums',:action=>'create',:format=>'js'},:method => 'post',:remote=>'true') do |f| %>
|
||||
<div class="mt15">
|
||||
<textarea type="text" name="forum[name]" id="forum_name" class="postCreateInput" onfocus="hideError();" onblur="check_forum_name();" placeholder="输入贴吧名称" ></textarea>
|
||||
<textarea type="text" name="forum[name]" id="forum_name" maxlength="80" class="postCreateInput" onfocus="hideError();" onblur="check_forum_name();" placeholder="输入贴吧名称" ></textarea>
|
||||
<script>
|
||||
var textarea = document.getElementById('forum_name');
|
||||
autoTextarea(textarea);
|
||||
</script>
|
||||
</div>
|
||||
<div class="mt15">
|
||||
<textarea type="text" name="forum[description]" id="forum_desc" class="postCreateInput" placeholder="输入贴吧描述"></textarea>
|
||||
<textarea type="text" name="forum[description]" id="forum_desc" maxlength="5000" class="postCreateInput" placeholder="输入贴吧描述"></textarea>
|
||||
<script>
|
||||
var textarea1 = document.getElementById('forum_desc');
|
||||
autoTextarea(textarea1);
|
||||
|
|
|
@ -92,14 +92,14 @@
|
|||
<div id="error" class="red fl mb10" style="display: none">error</div>
|
||||
<%= labelled_form_for(@memo, :url => forum_memos_path(@forum)) do |f| %>
|
||||
<div>
|
||||
<textarea type="text" name="memo[subject]" id="memo_subject" onblur="check_memo_name();" onfocus="$('#error').hide();" onmouseover="this.style.borderColor='#d9d9d9'" class="postDetailInput" placeholder="输入帖子标题" ></textarea>
|
||||
<textarea type="text" name="memo[subject]" id="memo_subject" maxlength="50" onblur="check_memo_name();" onfocus="$('#error').hide();" onmouseover="this.style.borderColor='#d9d9d9'" class="postDetailInput" placeholder="输入帖子标题" ></textarea>
|
||||
<script>
|
||||
var textarea1 = document.getElementById('memo_subject');
|
||||
autoTextarea(textarea1);
|
||||
</script>
|
||||
</div>
|
||||
<div class="mt15">
|
||||
<textarea type="text" name="memo[content]" id="memo_content" onfocus="$('#error').hide();" onmouseover="this.style.borderColor='#d9d9d9'" class="postDetailInput" placeholder="输入帖子内容" /></textarea>
|
||||
<textarea type="text" name="memo[content]" id="memo_content" maxlength="5000" onfocus="$('#error').hide();" onmouseover="this.style.borderColor='#d9d9d9'" class="postDetailInput" placeholder="输入帖子内容" /></textarea>
|
||||
<script>
|
||||
var textarea = document.getElementById('memo_content');
|
||||
autoTextarea(textarea);
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
<%= javascript_include_tag 'new_user'%>
|
||||
<script>
|
||||
$(function(){
|
||||
limitStrsize('memo_subject',50);
|
||||
limitStrsize('memo_content',5000);
|
||||
});
|
||||
|
||||
function check_and_submit(){
|
||||
if($("textarea[name='memo[subject]']").val().trim() != "" && $("textarea[name='memo[content]']").val().trim() != "" ){
|
||||
if($("textarea[name='memo[subject]']").val().trim().length > 50 ){
|
||||
$("#error").html('主题不能超过50个字符').show();
|
||||
return;
|
||||
}
|
||||
if($("textarea[name='memo[content]']").val().trim().length > 5000 ){
|
||||
$("#error").html('内容不能超过5000个字符').show();
|
||||
return;
|
||||
}
|
||||
$("#edit_memo").submit();
|
||||
}else if($("textarea[name='memo[subject]']").val().trim() == "" && $("textarea[name='memo[content]']").val().trim() != "" ){
|
||||
$("#error").html("主题不能为空").show();
|
||||
|
@ -19,7 +24,7 @@
|
|||
</div>
|
||||
<div class="postRightContainer" style="margin-top: 15px">
|
||||
<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo),:html=>{:id=>'edit_memo'}) do |f| %>
|
||||
<div id="error" style="display: none">
|
||||
<div id="error" style="color:red ;display: none">
|
||||
|
||||
</div>
|
||||
<div>
|
||||
|
@ -45,3 +50,9 @@
|
|||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
limitStrsize('memo_subject',50);
|
||||
limitStrsize('memo_content',5000);
|
||||
});
|
||||
</script>
|
|
@ -340,7 +340,7 @@ function limitStrsize(id,length){
|
|||
$('#'+id).keypress(function(e)
|
||||
{
|
||||
var n = 0;
|
||||
var str = this.value;
|
||||
var str = this.val().trim();
|
||||
for (i = 0; i < str.length; i++) {
|
||||
var leg = str.charCodeAt(i);//ASCII码
|
||||
if (leg > 255) {//大于255的都是中文
|
||||
|
|
Loading…
Reference in New Issue