1、键入时候保存数字,
问题:多个输入框的时候,连续输入非数字,导致删除的非数字出现
οnkeyup="this.value=this.value.replace(/\D/g,'')"
2、onkeypress,返回true和false来设置是否键入
type="number" maxlength="4" οnkeypress="return (/[1-9][/d]*/.test(String.fromCharCode(event.keyCode)))"
消除type=input的箭头
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
}
input[type="number"]{
-moz-appearance: textfield;
}
鼠标滚动 type= number
汉字,字母,数字的输入
3.type=number maxlength失效的问题 οninput="if(value.length>4)value=value.slice(0,4)"
http升级为https
//校验输入框的输入数字且不以0开始
window.keyPressVeriNum = (value, event) => {
if(value.length == 0)
{
return (/[1-9]/.test(String.fromCharCode(event.keyCode)))
} else{
return (/[\d]/.test(String.fromCharCode(event.keyCode)))
}
}
οnkeypress="return keyPressVeriNum (value, event)"
keyPressVeri (value, event)
type="number" onmousewheel="return false" οninput="if(value.length>11)value=value.slice(0,11)" οnkeypress="return keyPressVeriNum(value, event, false)"
对规格去掉的情况
type="number" onmousewheel="return false" οninput="if(value.length>11)value=value.slice(0,11)" οnkeypress="return keyPressVeriNum(value, event, true,0,0,2)"
/^1\d{10}$|^0\d{2,3}-\d{7,8}$/
三元运算符设置多类名
<div :class="type==1?'box-bottom':'box-bottom isDaily'" >
var reg = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i;