![3730cf22d07c3402c74b491f4d0948c1.png](https://img-blog.csdnimg.cn/img_convert/3730cf22d07c3402c74b491f4d0948c1.png)
禁止input输入所有空格
方法1
<input type="text" onKeypress="javascript:if(event.keyCode == 32)event.returnValue = false;" />
方法2
<input type="text" onkeyup="this.value=this.value.replace(/^s+|s+$/g,'')">
去字符串的首尾空格
String.prototype.trim()
<input type="test" v-model.trim="keyword" >
注意:是提交字段的时候去除首尾空格,但是空格还是能够输入的
禁止输入首尾空格,能输入中间空格
方法1