jquery 自动过滤表单输入框前后空格

前提引入jquery.js

 1 $(document).ready(function()  {
 2            $('#searchform input').keyup(trimkeyup);
 3}
);
 4 function trimkeyup(e)  {
 5    lucene_objInput = $(this);
 6    if (e.keyCode != 38 && e.keyCode != 40 && e.keyCode != 13{
 7        var im = $.trim(lucene_objInput.val());
 8        lucene_objInput.val(im); 
 9    }

10}
        



 1          < form id = " searchform "  name = " searchform "  action = " listPsInfo.action "  method = " post " >
 2          < div id = " sr "   class = " b1 mb10 " >
 3              < ul id = " sr_bq " >
 4                  < li  class = " on " >
 5                      < div >
 6                         查询员工信息
 7                      </ div >
 8                  </ li >
 9              </ ul >
10              < select  class = " sa_w_tx "  style = " width: 100px; "  id = " selectType "  name = " psInfoDO.name " >
11                    < option value = " 1 "   < s: if  test = " optionValue==1 " > selected = " selected " </ s: if >> 工号 </ option >
12                    < option value = " 2 "   < s: if  test = " optionValue==2 " > selected = " selected " </ s: if >> 旺旺(花名) </ option >
13                    < option value = " 3 "   < s: if  test = " optionValue==3 " > selected = " selected " </ s: if >> 真实姓名 </ option >
14                    < option value = " 4 "   < s: if  test = " optionValue==4 " > selected = " selected " </ s: if >> 邮箱 </ option >
15              </ select >  
16              < input type = " text "   class = " sa_w_tx "  style = " width: 180px; "  id = " textValue "  name = " psInfoDO.value "  value = " <s:property value= " psInfoDO.value " /> "  maxlength = " 100 "  title = " 请输入相应内容  不允许空值 "   />& nbsp; & nbsp;
17               < input type = " button "  value = " 查询 "   class = " btn1 "  id = " subform "  onclick = " dosearch(); " />& nbsp; & nbsp;  < div id = " errortip " ></ div >
18              </ form >

页面中所有的input输入框都会自动过滤前后空格

你可能感兴趣的:(jquery 自动过滤表单输入框前后空格)