输入框自动清除首尾空格
在输入框加入onkeyup="this.value=this.value.replace(/^\s+|\s+$/g,‘‘)"
<input type="text" placeholder="输入查询" onkeyup="this.value=this.value.replace(/^\s+|\s+$/g,‘‘)">
原文:http://www.cnblogs.com/leiting/p/7675459.html