<input id="uxKeywords" name="search" class="search J_Search_WM" type="text" placeholder="请输入XXXX"
onkeypress="enterPress(event);" />
input type="button" class="a-btn search-blue-btn" onclick="searchvalidate();" value="搜索" />
<script type="text/
javascript">
//绑定onkeypress事件,为回车键提供初始化事件
function enterPress(e) {
if (e.keyCode == 13) {
searchvalidate();
event.returnValue = false;//阻止自动提交
}
}
function searchvalidate() {
var kw = $("#uxKeywords").val();
if (kw.replace(/s+/g, "") == "") {
alert("请输入关键词");
}
else {
openSearchUrl(kw);
}
}
function openSearchUrl(keyword) {
var url = $("#hdSearchLink").val().replace("p_kw", encodeURIComponent(keyword));
window.open(url, "", "", "");
}
</script>