当前位置: 代码迷 >> 综合 >> 禁止输入框输入空格
  详细解决方案

禁止输入框输入空格

热度:56   发布时间:2023-09-22 15:22:26.0

<input type="text" οnkeyup="this.value=this.value.replace(/^ +| +$/g,'')" placeholder="输入...">

<input type="text" οnkeydοwn="if(event.keyCode==32){return false;}"  placeholder="输入..."> (空格的keycode为32)

  相关解决方案