万一长度过大,阻止提交
This commit is contained in:
parent
c8cbab2d50
commit
959d3f1a93
|
@ -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>
|
Loading…
Reference in New Issue