取消回复帖子时对主题的js验证

This commit is contained in:
sw 2014-10-27 14:29:49 +08:00
parent e220f100d6
commit cf9f33fce7
3 changed files with 32 additions and 5 deletions

View File

@ -181,7 +181,7 @@
<div id="reply" style="display:none;">
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
<input type="button" class="enterprise" value="<%=l(:button_submit) %>" onmousemove="regexContent()" onclick="submit_message_replay();" >
<input type="button" class="enterprise" value="<%=l(:button_submit) %>" onclick="submit_message_replay();" >
<% end %>
<div id="preview" class="wiki"></div>
</div>
@ -190,7 +190,7 @@
<% html_title @topic.subject %>
<script type="text/javascript">
var flag = false
var flag = false;
jQuery(document).ready(function($) {
transpotUrl('#content');
});

View File

@ -46,7 +46,11 @@
<span class="required"> *&nbsp;&nbsp;</span>
</label>
<br/>
<%= f.text_field :subject, { size: 60, style: "width: 99%;", id: "message_subject", onblur: "regexSubject();" }.merge(extra_option) %>
<% if replying %>
<%= f.text_field :subject, { size: 60, style: "width: 99%;", id: "message_subject" }.merge(extra_option) %>
<% else %>
<%= f.text_field :subject, { size: 60, style: "width: 99%;", id: "message_subject", onblur: "regexSubject();" }.merge(extra_option) %>
<% end %>
<span id="subject_span"></span>
</p>
<p>

View File

@ -181,15 +181,38 @@
<div id="reply" style="display:none;">
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
<%= submit_tag l(:button_submit) %>
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
<input type="button" class="enterprise" value="<%=l(:button_submit) %>" onclick="submit_message_replay();" >
<% end %>
<div id="preview" class="wiki"></div>
</div>
<% end %>
<% html_title @topic.subject %>
<script type="text/javascript">
var flag = false;
jQuery(document).ready(function($) {
transpotUrl('#content');
});
function submit_message_replay()
{
if(flag)
{
$("#message-form").submit();
}
}
function regexContent()
{
var content = $.trim($("#message_content").val());
if(content.length ==0)
{
$("#message_content_span").text("<%= l(:label_reply_empty) %>");
$("#message_content_span").css('color','#ff0000');
flag = false;
}
else
{
$("#message_content_span").text("<%= l(:label_field_correct) %>");
$("#message_content_span").css('color','#008000');
flag = true;
}
}
</script>