input在标签内设置禁止输入空格

1.通过正则匹配解决问题

此处涉及\s:匹配任意空白符  \S:匹配任意非空白字符

<input type="text" onkeyup="this.value=this.value.replace(/\s+/g,'')">

 

 

posted @ 2017-01-05 14:03  九门提督琪琪  阅读(22718)  评论(0编辑  收藏  举报