修改竞赛通知new页面代码:

1.增加js验证,
2.修复点击取消按钮却提交通知的BUG
This commit is contained in:
sw 2014-10-23 10:57:23 +08:00
parent 943df643aa
commit d2f4b38eb6
3 changed files with 65 additions and 57 deletions

View File

@ -1,4 +1,55 @@
<%= error_messages_for @contestnotifications %> <%= error_messages_for @contestnotifications %>
<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;
}
}
</script>
<div class="add_frame_header" > <div class="add_frame_header" >
<%= l(:bale_news_notice) %> <%= l(:bale_news_notice) %>
</div> </div>

View File

@ -1,53 +1,4 @@
<script type="text/javascript"> <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() function submitContestNews()
{ {
if(regexTitle() && regexDescription()) if(regexTitle() && regexDescription())

View File

@ -1,11 +1,17 @@
<script type="text/javascript">
function submitContestNews()
{
if(regexTitle() && regexDescription())
{
$("#contestnotifications-form").submit();
}
}
</script>
<%= labelled_form_for @contestnotification, <%= labelled_form_for @contestnotification,
:url => contest_contestnotifications_path(@contest), :url => contest_contestnotifications_path(@contest),
:html => { :id => 'contestnotifications-form', :multipart => true } do |f| %> :html => { :id => 'contestnotifications-form', :multipart => true } do |f| %>
<%= render :partial => 'contestnotifications/form', :locals => { :f => f } %> <%= render :partial => 'contestnotifications/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %> <input type="button" onclick="submitContestNews();" class="enterprise" value="<%= l(:button_create)%>"/>
<input type="button" onclick="$('#add-contestnotifications').hide(); return false;" class="enterprise" value="<%= l(:button_cancel)%>"/> <%= link_to l(:button_cancel), contest_contestnotifications_path(@contest.id) %>
<% end %> <% end %>
<div id="preview" class="wiki"></div> <div id="preview" class="wiki"></div>