搜索项目时增加js验证增加

This commit is contained in:
sw 2015-01-30 11:00:18 +08:00
parent 0d5384c6d8
commit a265556cfe
2 changed files with 88 additions and 21 deletions

View File

@ -36,13 +36,41 @@
<td class="info_font" style="width: 240px; color: #15bccf">软件项目托管社区</td> <td class="info_font" style="width: 240px; color: #15bccf">软件项目托管社区</td>
<td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td> <td style="width: 430px; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
<td rowspan="2" width="250px"> <td rowspan="2" width="250px">
<div class="top-content-search" style="display:none"> <div class="top-content-search">
<%= form_tag(projects_search_path, :method => :get) do %> <script type="text/javascript">
<%= text_field_tag 'name', params[:name], :size => 20 %> function regexName()
<%= hidden_field_tag 'project_type', params[:project_type] %> {
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %> var name = $.trim($("#name").val());
<% end %> if(name.length == 0)
</div> {
$("#project_name_span").text("<%= l(:label_search_conditions_not_null) %>");
$("#project_name_span").css('color','#ff0000');
$("#project_name_span").focus();
return false;
}
else
{
$("#project_name_span").text("");
return true;
}
}
function submitSerch()
{
if(regexName()){$("#project_search_form").submit();}
}
</script>
<%= form_tag(projects_search_path, :method => :get, :id => "project_search_form") do %>
<%= text_field_tag 'name', params[:name], :size => 20, :onkeyup => "regexName();", :style => "float:left" %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<a href="#" onclick="submitSerch();" class="ButtonColor m3p10" style="float:left;padding-top: 3px; margin: 0px;padding-bottom:0px;" >
<%= l(:label_search)%>
</a>
<br />
<span id="project_name_span" style="float: left"></span>
<% end %>
</div>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@ -4,7 +4,7 @@
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
<% end %> <% end %>
<div class="top-content"> <div class="top-content">
<%= form_tag(projects_search_path, :method => :get) do %> <%= form_tag(projects_search_path, :method => :get, :id => "project_search_form") do %>
<% if params[:project_type] == "1" %> <% if params[:project_type] == "1" %>
<table width="940px"> <table width="940px">
<tr> <tr>
@ -33,24 +33,63 @@
<% else %> <% else %>
<table width="940px"> <table width="940px">
<tr> <tr>
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_project_deposit) %></td> <td class="info_font" style="width: 220px; color: #15bccf">
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td> <%= l(:label_project_deposit) %>
</td>
<td class="location-list">
<strong><%= l(:label_user_location) %> :</strong>
</td>
<td rowspan="2" valign="bottom"> <td rowspan="2" valign="bottom">
<% if User.current.logged? %> <% if User.current.logged? %>
<%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %>
<% end %> <% end %>
</td> </td>
<td rowspan="2" > <td rowspan="2" >
<div class="project-search" style="float: right"> <script type="text/javascript">
<%= text_field_tag 'name', params[:name], :size => 30 %> function regexName()
<%= hidden_field_tag 'project_type', params[:project_type] %> {
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %> var name = $.trim($("#name").val());
</div> if(name.length == 0)
{
$("#project_name_span").text("<%= l(:label_search_conditions_not_null) %>");
$("#project_name_span").css('color','#ff0000');
$("#project_name_span").focus();
return false;
}
else
{
$("#project_name_span").text("");
return true;
}
}
function submitSerch()
{
if(regexName()){$("#project_search_form").submit();}
}
</script>
<div class="project-search" style="float: right">
<%= text_field_tag 'name', params[:name], :size => 20, :onkeyup => "regexName();", :style => "float:left" %>
<%= hidden_field_tag 'project_type', params[:project_type] %>
<%#= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
<a href="#" onclick="submitSerch();" class="ButtonColor m3p10" style="float:left;padding-top: 3px; margin: 0px;padding-bottom:0px;" >
<%= l(:label_search)%>
</a>
<br />
<span id="project_name_span" style="float: left"></span>
</div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="padding-left: 8px"><a><%= link_to request.host()+"/projects", :controller => 'projects', :action => 'index', :project_type => 0 %> </a></td> <td style="padding-left: 8px">
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_project_deposit), :controller => 'projects', :action => 'index', :project_type => 0 %></td> <a>
<%= link_to request.host()+"/projects", :controller => 'projects', :action => 'index', :project_type => 0 %>
</a>
</td>
<td >
<%=link_to l(:field_homepage), home_path %> >
<%=link_to l(:label_project_deposit), :controller => 'projects', :action => 'index', :project_type => 0 %>
</td>
</tr> </tr>
</table> </table>
<% end %> <% end %>