$(document).ready(function(){ $("#id_searchBox").focus(function() { funcFocus("id_searchBox");}); $("#id_searchBox_sm").focus(function() {funcFocus("id_searchBox_sm");}); $("#id_searchBox").blur(function() { funcBlur("id_searchBox");}); $("#id_searchBox_sm").blur(function() {funcBlur("id_searchBox_sm");}); $("#id_searchButton").click( function() { if($("#id_searchBox").val() != "" && $("#id_searchBox").val() != ""){ location.href="http://kochi-bosai.com/product/?freeword=" + $("#id_searchBox").val(); return true; } } ); $("#id_searchButton_sm").click( function() { if($("#id_searchBox_sm").val() != "" && $("#id_searchBox_sm").val() != ""){ location.href="http://kochi-bosai.com/product/?freeword=" + $("#id_searchBox_sm").val(); return true; } } ); $("#id_searchBox").keydown( function(e) { if(e.keyCode == 13){ if($("#id_searchBox").val() != "" && $("#id_searchBox").val() != ""){ location.href="http://kochi-bosai.com/product/?freeword=" + $("#id_searchBox").val(); return false; } return false; } } ); $("#id_searchBox_sm").keydown( function(e) { if(e.keyCode == 13){ if($("#id_searchBox_sm").val() != "" && $("#id_searchBox_sm").val() != ""){ location.href="http://kochi-bosai.com/product/?freeword=" + $("#id_searchBox_sm").val(); return false; } return false; } } ); }); function funcFocus(item){ if($("#" + item).val() == "") { $("#" + item).val(""); } return true; } function funcBlur(item){ if($("#" + item).val() == "") { $("#" + item).val(""); } return true; }