input表单禁止输入空格

input在标签内设置禁止输入空格,通过正则匹配解决问题


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


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

猜你喜欢

转载自blog.csdn.net/yufengaotian/article/details/79231992