#1397、#1396新建竞赛通知增加js验证

course_group
sw 11 years ago
parent 91d08d5b9a
commit 923a33add5

@ -3,24 +3,27 @@
<%= l(:bale_news_notice) %>
</div>
<div class="box tabular">
<p>
<%= f.text_field :title,
:required => true,
:size => 60,
:maxlength => 60,
:style => "width:488px;"
%>
</p>
<p>
<%= f.text_area :description,
:required => true,
:cols => 60,
:rows => 11,
:class => 'wiki-edit',
:style => "width:490px;"
%>
</p>
<p>
<%= f.text_field :title,
:required => true,
:size => 60,
:maxlength => 60,
:style => "width:488px;",
:onblur => "regexTitle();"
%>
</p>
<span id="title_span" style="padding-left: 100px;"></span>
<p>
<%= f.text_area :description,
:required => true,
:cols => 60,
:rows => 11,
:class => 'wiki-edit',
:style => "width:490px;",
:onblur => "regexDescription();"
%>
</p>
<span id="description_span" style="padding-left: 100px;"></span>
</div>
<%= wikitoolbar_for 'news_description' %>

@ -1,3 +1,62 @@
<script type="text/javascript">
function regexTitle()
{
var title = $.trim($("#contestnotification_title").val());
if(title.length ==0)
{
$("#title_span").text("<%= l(:label_no_contest_news_title) %>");
$("#title_span").css('color','#ff0000');
$("#title_span").focus();
return false;
}
else if(title.length <= 254)
{
$("#title_span").text("<%= l(:label_field_correct) %>");
$("#title_span").css('color','#008000');
return true;
}
else
{
$("#title_span").text("<%= l(:label_contest_news_title_condition) %>");
$("#title_span").css('color','#ff0000');
$("#title_span").focus();
return false;
}
}
//验证描述不能为空不能多余5000个字符
function regexDescription()
{
var description = $.trim($("#contestnotification_description").val());
if(description.length ==0)
{
$("#description_span").text("<%= l(:label_no_contest_news_description) %>");
$("#description_span").css('color','#ff0000');
$("#description_span").focus();
return false;
}
else if(description.length <= 5000)
{
$("#description_span").text("<%= l(:label_field_correct) %>");
$("#description_span").css('color','#008000');
return true;
}
else
{
$("#description_span").text("<%= l(:label_contest_news_condition) %>");
$("#description_span").css('color','#ff0000');
$("#description_span").focus();
return false;
}
}
function submitContestNews()
{
if(regexTitle() && regexDescription())
{
$("#contestnotifications-form").submit();
}
}
</script>
<span style="font-size: 16px; border-bottom:1px solid #f0f0f0; margin-right: 15px;">
<%= l(:label_notification) %>
</span>
@ -12,10 +71,9 @@
<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest),
:html => {:id => 'contestnotifications-form', :multipart => true} do |f| %>
<%= render :partial => 'contestnotifications/form', :locals => {:f => f} %>
<%= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %>
<%#= preview_link preview_contestnotifications_path(:contest_id => @contest), 'contestnotifications-form', target='preview', {:class => 'whiteButton m3p10'} %>
<input type="button" onclick="submitContestNews();" class="enterprise" value="<%= l(:button_create)%>"/>
|
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-contestnotifications").hide(); return false;', :class => 'whiteButton m3p10' %>
<input type="button" onclick="$('#add-contestnotifications').hide(); return false;" class="enterprise" value="<%= l(:button_cancel)%>"/>
<% end if @contest %>
<div id="preview" class="wiki"></div>
</div>

@ -2165,3 +2165,7 @@ zh:
lable_course_teacher: 主讲老师
lable_course_end: 课程学期已结束
lable_file_sharingarea: 资源共享区
label_no_contest_news_description: 竞赛描述不能为空
label_contest_news_condition: 竞赛描述超过5000个汉字
label_no_contest_news_title: 竞赛标题不能为空
label_contest_news_title_condition: 竞赛标题超过255个汉字

Loading…
Cancel
Save