1.新建竞赛作品增加js验证

2.修复上传图片一次超过2张,上传失败的BUG
This commit is contained in:
sw 2014-08-16 13:30:38 +08:00
parent 8d03068ce2
commit 9688a73aa1
2 changed files with 106 additions and 18 deletions

View File

@ -13,16 +13,17 @@
<% end %>
</span>
<script type='text/javascript'>
function CompatibleSend()
{
var obj=document.getElementById("_file");
var file= $(obj).clone();
file.click();
}
// function CompatibleSend()
// {
// var obj=document.getElementById("_file");
// var file= $(obj).clone();
// file.click();
// }
</script>
<span class="add_attachment">
<%= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
<!--%= link_to image_tag(),"javascript:void(0)", :onclick => "_file.click()"%-->
<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()" %>
<%= file_field_tag 'attachments[dummy][file]',
:id => '_file',
:class => 'file_selector',

View File

@ -1,12 +1,98 @@
<%#= error_messages_for 'softapplication' %>
<script type="text/javascript">
//验证作品名称
function regexName()
{
var name = $("#softapplication_name").val();
if(name.length ==0)
{
$("#spane_name_notice").text("作品名称不能为空");
$("#spane_name_notice").css('color','#ff0000');
$("#spane_name_notice").focus();
return false;
}
else if(name.length < 25)
{
$("#spane_name_notice").text("填写正确");
$("#spane_name_notice").css('color','#008000');
return true;
}
else
{
$("#spane_name_notice").text("作品名称超过25个汉字");
$("#spane_name_notice").css('color','#ff0000');
$("#spane_name_notice").focus();
return false;
}
}
//验证运行平台
function regexWorkdescription()
{
var workDescription = $("#softapplication_android_min_version_available").val();
if(workDescription.length ==0)
{
$("#spane_workdescription_notice").text("运行平台不能为空");
$("#spane_workdescription_notice").css('color','#ff0000');
return false;
}
if(workDescription.length < 125)
{
$("#spane_workdescription_notice").text("填写正确");
$("#spane_workdescription_notice").css('color','#008000');
return true;
}
else
{
$("#spane_workdescription_notice").text("运行平台超过125个汉字");
$("#spane_workdescription_notice").css('color','#ff0000');
return false;
}
}
//验证开发人员
function regexDevelopers()
{
var workDescription = $("#softapplication_application_developers").val();
if(workDescription.length ==0)
{
$("#span_softapplication_application_developers").text("开发人员不能为空");
$("#span_softapplication_application_developers").css('color','#ff0000');
return false;
}
if(workDescription.length < 125)
{
$("#span_softapplication_application_developers").text("填写正确");
$("#span_softapplication_application_developers").css('color','#008000');
return true;
}
else
{
$("#span_softapplication_application_developers").text("开发人员超过125个汉字");
$("#span_softapplication_application_developers").css('color','#ff0000');
return false;
}
}
//提交验证
function submit_new_softapplication()
{
if(regexName() && regexWorkdescription() && regexDevelopers())
{
alert("123123123123");
$("#new_softapplication").submit();
}
}
</script>
<%= form_for Softapplication.new, :url => softapplications_path do |f| %>
<fieldset class="contes-new-box" style="padding-left: 36px; line-height: 8px; margin-left: 1px" >
<%= hidden_field_tag 'contest_id', @contest.id %>
<tr style="width:700px; margin-left: -10px;">
<span><%= l(:label_work_name) %></span>
<span class="contest-star"> * </span>:
<td><%= f.text_field :name, :required => true, :size => 60, :style => "width:350px;" %></td>
<span style="font-size: 10px">(<%= l(:label_workname_lengthlimit) %>)</span>
<td><%= f.text_field :name, :required => true, :size => 60, :style => "width:320px;", :onblur => "regexName();" %></td>
<span style="font-size: 10px;" id="spane_name_notice">(<%= l(:label_workname_lengthlimit) %>)</span>
</tr>
<br/>
<br/>
@ -16,9 +102,9 @@
<span><%= l(:label_running_platform) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px">
<%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:350px;" %>
<%= f.text_field :android_min_version_available, :required => true, :size => 60, :style => "width:320px;", :onblur=>"regexWorkdescription();"%>
</td>
<span style="font-size: 10px">(<%= l(:label_workdescription_lengthlimit) %>)</span>
<span style="font-size: 10px" id="spane_workdescription_notice">(<%= l(:label_workdescription_lengthlimit) %>)</span>
</tr>
<br/>
<br/>
@ -31,12 +117,12 @@
<span>
<%#= select_tag 'app_type_name', work_type_opttion, {:name => 'app_type_name',:style => "width:358px;"} %>
</span>
<%= f.select :app_type_name,work_type_opttion, {},{:style => "width:358px;",:onchange => "selectChange(this)"} %>
<%= f.select :app_type_name,work_type_opttion, {},{:style => "width:328px;",:onchange => "selectChange(this)"} %>
<%#= f.text_field :app_type_name, :required => true, :size => 60, :style => "width:400px;" %>
</td>
<span style="font-size: 10px;display: none" id="other_span">
<%#= f.text_field :other_input, :required => true, :size => 60, :style => "width:100px;" %>
<input type="text" style="width: 100px;" id="other_input" name = "other_input"/>
<input type="text" style="width: 120px;" id="other_input" name = "other_input"/>
</span>
</tr>
<br/>
@ -46,7 +132,7 @@
<tr style="width:800px;">
<span><%= l(:label_work_description) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:350px;" %></td>
<td style="width: 100px"><%= f.text_field :description, :required => true, :size => 60, :style => "width:320px;" %></td>
<!--span style="font-size: 10px">(<%#= l(:label_workdescription_lengthlimit) %>)</span-->
</tr>
<br/>
@ -56,8 +142,8 @@
<tr style="width:800px;">
<span><%= l(:label_softapplication_developers) %></span>
<span class="contest-star"> * </span>:
<td style="width: 100px"><%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:350px;" %></td>
<span style="font-size: 10px">(<%= l(:label_workdescription_lengthlimit) %>)</span>
<td style="width: 100px"><%= f.text_field :application_developers, :required => true, :size => 60, :style => "width:320px;", :onblur => 'regexDevelopers();' %></td>
<span style="font-size: 10px" id="span_softapplication_application_developers">(<%= l(:label_workdescription_lengthlimit) %>)</span>
</tr>
<br/>
<br/>
@ -65,7 +151,7 @@
<tr style="width:800px;">
<span><%= l(:label_work_deposit_project) %></span>
<span style="padding-left: 4px"><%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:358px;" %></span>
<span style="padding-left: 4px"><%= select_tag 'project', options_for_select(select_option_helper(@option)), :name => 'project', :class => 'grayline2',:style => "width:328px;" %></span>
<span><%= link_to l(:label_create_new_projects),{:controller => 'projects',:action => 'new',course: 0, project_type: 0,host: Setting.project_domain}, :target => '_blank' %></span><!-- new_project_path(course: 0, project_type: 0) -->
</tr>
<br/>
@ -90,7 +176,8 @@
</fieldset>
</fieldset></br>
<div class="align-center" style="padding-top: -3px; padding-bottom: 8px">
<%= submit_tag l(:button_create) %>
<input type="button" class="enterprise" value="<%=l(:button_create) %>" onclick="submit_new_softapplication();" >
<%#= submit_tag l(:button_create) %>
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();",
:type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'",
:onmouseover => "this.style.backgroundPosition = 'left -30px'" %>