input禁止输入空格 以及 input各种输入限制

1.禁止输入空格

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

2.只能输入纯数字

<input type="text"  maxlength="13" v-model="phone" oninput="value=value.replace(/[^\d]/g,'')" placeholder="请输入手机号/QQ号"></div>

猜你喜欢

转载自www.cnblogs.com/520BigBear/p/12922925.html