输入为空不提交表单
This commit is contained in:
parent
63c7ea8d4e
commit
6d768100f8
|
@ -33,12 +33,21 @@
|
|||
|
||||
$(function(){
|
||||
$("#navHomepageSearchInput").keypress(function(e){
|
||||
if (e.keyCode == '13') {
|
||||
var name = $.trim($('#navHomepageSearchInput').val());
|
||||
if (e.keyCode == '13' && name != "" && name.length != 0) {
|
||||
$('#type').val($('input[type=radio]:checked').val());
|
||||
$(this).parent().submit();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function search_in_header(){
|
||||
var name = $.trim($('#navHomepageSearchInput').val());
|
||||
if (name != "" && name.length != 0) {
|
||||
$('#type').val($('input[type=radio]:checked').val());
|
||||
$(this).parent().submit();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<div class="fl" id="navHomepageSearch">
|
||||
<!--<form class="navHomepageSearchBox">-->
|
||||
|
@ -46,9 +55,10 @@
|
|||
|
||||
<%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %>
|
||||
<input type="text" name="q" value="<%= name.nil? ? "" : name%>" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词进行搜索"/>
|
||||
<input type="hidden" name="search_type" id="type" value=""/>
|
||||
<a href="javascript:void(0);" class="homepageSearchIcon" onclick="$('#type').val($('input[type=radio]:checked').val());$(this).parent().submit();"></a>
|
||||
<% end %>
|
||||
<input type="hidden" name="search_type" id="type" value=""/>
|
||||
<input type="text" class="none"/>
|
||||
<a href="javascript:void(0);" class="homepageSearchIcon" onclick="search_in_header();"></a>
|
||||
<% end %>
|
||||
<div class="navSearchTypeBox" id="navHomepageSearchType">
|
||||
<div class="fl mr15 mt8">
|
||||
<input type="radio" value="courses" name="search_type" checked/>
|
||||
|
|
|
@ -33,22 +33,40 @@
|
|||
|
||||
$(function(){
|
||||
$("#navHomepageSearchInput").keypress(function(e){
|
||||
if (e.keyCode == '13') {
|
||||
var name = $.trim($('#navHomepageSearchInput').val());
|
||||
if (e.keyCode == '13' && name != "" && name.length != 0) {
|
||||
$('#type').val($('input[type=radio]:checked').val());
|
||||
$(this).parent().submit();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function search_in_header(){
|
||||
var name = $.trim($('#navHomepageSearchInput').val());
|
||||
if (name != "" && name.length != 0) {
|
||||
$('#type').val($('input[type=radio]:checked').val());
|
||||
$(this).parent().submit();
|
||||
}
|
||||
}
|
||||
|
||||
//搜索相关
|
||||
$("#navHomepageSearch").mouseover(function(){
|
||||
$("#navHomepageSearchType").show();
|
||||
}).mouseout(function(){
|
||||
$("#navHomepageSearchType").hide();
|
||||
});
|
||||
</script>
|
||||
<div class="fl" id="navHomepageSearch">
|
||||
<!--<form class="navHomepageSearchBox">-->
|
||||
<% name = name%>
|
||||
|
||||
<%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %>
|
||||
<input type="text" name="q" value="<%= name.nil? ? "" : name%>" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词进行搜索" />
|
||||
<input type="hidden" name="search_type" id="type" value=""/>
|
||||
<a href="javascript:void(0);" class="homepageSearchIcon" onclick="$('#type').val($('input[type=radio]:checked').val());$(this).parent().submit();"></a>
|
||||
<input type="text" name="q" value="<%= name.nil? ? "" : name%>" id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词进行搜索"/>
|
||||
<input type="hidden" name="search_type" id="type" value=""/>
|
||||
<input type="text" class="none"/>
|
||||
<a href="javascript:void(0);" class="homepageSearchIcon" onclick="search_in_header();"></a>
|
||||
<% end %>
|
||||
|
||||
<div class="navSearchTypeBox" id="navHomepageSearchType">
|
||||
<div class="fl mr15 mt8">
|
||||
<input type="radio" value="courses" name="search_type" checked/>
|
||||
|
@ -75,13 +93,3 @@
|
|||
<a href="<%= signin_path(:login=>false) %>" class="c_white db">注册</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
//搜索相关
|
||||
$("#navHomepageSearch").mouseover(function(){
|
||||
$("#navHomepageSearchType").show();
|
||||
}).mouseout(function(){
|
||||
$("#navHomepageSearchType").hide();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue